在Login窗体中,我需要glyphicon-remove在每个验证消息的末尾都有相应字段名称的图标.所以我在下面的代码中使用了Login model.
['email', 'required', 'message' => 'Email cannot be blank<span class="glyphicon glyphicon-remove"></span>'],
['password', 'required', 'message' => 'Password cannot be blank<span class="glyphicon glyphicon-remove"></span>']
Run Code Online (Sandbox Code Playgroud)
而不是上面的代码,有没有任何可能的方法来使用类似下面的代码.
[['email', 'password'], 'required', 'message' => $attribute.' cannot be blank<span class="glyphicon glyphicon-remove"></span>']
Run Code Online (Sandbox Code Playgroud)
上述代码的思想是为每个字段动态获取相应的字段名称.
请只做那些需要的.谢谢.
更新
这里我使用的HTML代码(<span class="glyphicon glyphicon-remove"></span>)通过使用正确输出encode=>'false'.但我需要的是不是为每个字段单独定义,而是需要为所有字段共同定义.
我有两个多个select2框,Box1选项是动态填充的,当我从这个选择框中选择任何选项时,它应该被添加到新的Box2.此方案根据需要运行.我面临的问题是.当我从Box1中删除任何选定的项目时,我可以从Box2中删除它.但如果在Box2中选择了该项目,它仍然存在.
例如:A,B,C是框1中的选定值,Box2填充了A,B,C.如果我在Box 2中选择B,c,如果我从Box1中删除B. 我的Box2项目现在将是AC.但是B,C仍将在Box2中保持选中状态.
任何人都可以帮助我解决这个棘手的问题.
$("#Box1").on("change", function() {
var box1List = $('#Box1').val();
$('#Box2').empty();
for (var key in box1List) {
var valueField = box1List[key];
var textField = $("#Box1 > option[value='"+valueField+"']").text();
$("#Box2").append($('<option>', {value: valueField, text: textField}));
}
});
$("#Box1").on("select2-removed", function(e) {
console.log("removed val=" + e.val + " choice=" + e.choice.text);
$('#Box2 option[value="'+e.val+'"]').remove();
});
Run Code Online (Sandbox Code Playgroud) 我正在开发一个cakephp项目,并且正在开发cakephp.正如标题中所提到的,我需要对mysql查询的结果集进行分页,以便在视图中显示它们.
通过这种方式,我可以对"Asin"模型的结果进行分页.
$this->paginate =array('Asin'=>array(
'fields' => array('sku','fnsku'),
'conditions' => $marketplace,
'page' => 1, 'limit' => 20,
'order' => array('Asin.asin' => 'asc')
)
$data = $this->paginate('Asin',$criteria);
Run Code Online (Sandbox Code Playgroud)
我还需要一种方法来对以下查询的结果集进行分页.
$resultset = $this->Asin->query("SELECT * FROM products INNER JOIN asins ON products.id=asins.id ORDER BY products.id");
Run Code Online (Sandbox Code Playgroud)
我该如何添加分页?
我可以使用什么函数来选择 class="rate_stars" 的子 div。
我有一个 1 - 5 的可变范围,我想选择具有该特定数据评级的子 div。
我试过了
$('rate_widget').find().attr('data-rating', info).prevAll().andSelf().addClass('ratings_vote');
Run Code Online (Sandbox Code Playgroud)
但它没有用。
<div id="r1" class="rate_stars"
data-post-id="<?php echo $post_id ?>"
data-user-id="<?php echo $user_id; ?>"
data-nonce="<?php echo $nonce ?>"
>
<div data-rating="1" class="ratings_stars"></div>
<div data-rating="2" class="ratings_stars"></div>
<div data-rating="3" class="ratings_stars"></div>
<div data-rating="4" class="ratings_stars"></div>
<div data-rating="5" class="ratings_stars"></div>
<div class="total_votes">vote data</div>
</div>
Run Code Online (Sandbox Code Playgroud) javascript ×2
jquery ×2
php ×2
cakephp ×1
cakephp-2.0 ×1
mysql ×1
pagination ×1
yii2 ×1
yii2-model ×1