如果复选框被选中,我想在文本字段上应用所需的验证,否则没有。我通过场景尝试但它不起作用,对于表单我使用'bootstrap.widgets.TbActiveForm'我的Yii版本:1.1.16-dev
问问题
464 次
1 回答
0
在模型规则部分
[['textfield'], 'required', 'when' => function ($model) {
return $model->chechboxStatus == '1';
}, 'whenClient' => "function (attribute, value) {
return $('#demo-chechboxstatus').prop('checked') == true;
}"],
或者如果您使用任何场景,那么您可以像这样使用
[['textfield'], 'required', 'when' => function ($model) {
return $model->chechboxStatus == '1';
}, 'whenClient' => "function (attribute, value) {
return $('#demo-chechboxstatus').prop('checked') == true;
}",'on'=>'create'],
于 2016-06-01T06:33:57.130 回答