yii设置场景后 页面自带js验证失效 。求助大神 [ 求助交流 ]
场景设置
public function scenarios(){
return [
'updates' => ['content','review','review_remark']
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['pid', 'capital_id', 'user_id', 'content', 'review'], 'required','on'=>'updates'],
[['pid', 'capital_id', 'user_id', 'review'], 'integer','on'=>'updates'],
[['content','review_remark'], 'string','on'=>'updates'],
[['created_at', 'updated_at', 'deleted_at'], 'safe'],
[['capital_id'], 'exist', 'skipOnError' => true, 'targetClass' => Capitals::className(), 'targetAttribute' => ['capital_id' => 'id']],
];
}
没有场景前
Query(document).ready(function () {
jQuery('#w0').yiiActiveForm([{"id":"capitalcomments-capital_id","name":"capital_id","container":".field-capitalcomments-capital_id","input":"#capitalcomments-capital_id","validate":function (attribute, value, messages, deferred, $form) {yii.validation.number(value, messages, {"pattern":/^\s*[+-]?\d+\s*$/,"message":"Capital ID必须是整数。","skipOnEmpty":1});}},{"id":"capitalcomments-user_id","name":"user_id","container":".field-capitalcomments-user_id",.............
场景scenarios声明后
script type="text/javascript">jQuery(document).ready(function () {
jQuery('#w0').yiiActiveForm([], []);
});</script></body>
共 0 条回复
没有找到数据。
鲁b-yii
注册时间:2016-04-25
最后登录:2016-09-20
在线时长:2小时19分
最后登录:2016-09-20
在线时长:2小时19分
- 粉丝0
- 金钱25
- 威望0
- 积分45