鲁b-yii 2016-04-25 11:11:01 2409次浏览 0条回复 0 0 0

场景设置

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>
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册