【发布时间】:2014-09-20 15:53:38
【问题描述】:
我尝试过使用 yii 场景来区分更新和创建新记录之间的规则。当我像下面这样放置场景时,记录不会验证表单并且场景不起作用。我想知道哪里出错了
return array(
array('first_name, second_name, username, password, email, skype, attachment, just, cv', 'required','on'=>'insert'),
array('first_name, second_name, username, password, email', 'required','on'=>'update'),
array('first_name, second_name, username, password, email, skype, status, attachment, just, cv', 'length', 'max'=>255),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('attachment, cv', 'file', 'types'=>'doc, docx, pdf, odt'),
array('re_password','compare','compareAttribute'=>'password'),
);
当我不使用场景时
return array(
array('first_name, second_name, username, password, email, skype, attachment, just, cv', 'required'),
array('first_name, second_name, username, password, email, skype, status, attachment, just, cv', 'length', 'max'=>255),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('attachment, cv', 'file', 'types'=>'doc, docx, pdf, odt'),
array('re_password','compare','compareAttribute'=>'password'),
);
这可行,但有一些列我不需要更新来打扰像 cv 和附件。
由于我遗漏了一些东西,请亮出一些光。
【问题讨论】: