[英]Unset validate rules in CakePHP
I want unset validate rules in beforValidate but I have notices: 我想在beforValidate中取消设置验证规则,但是我注意到:
Notice (8): Indirect modification of overloaded property User::$validate has no effect
My code: 我的代码:
function beforeValidate($options = array()) {
if (empty($this->data[$this->name]['name']) && empty($this->data[$this->name]['name2'])) {
unset(
$this->validate['name'], $this->validate['name2']
);
}
return true;
}
How can I unset rules without notices? 如何取消规则而不另行通知?
First step is to usually try the Amazing Online CakePHP Book . 第一步通常是尝试Amazing Online CakePHP Book 。
If you do that, you'll notice there's a section on how to remove validation rules . 如果这样做,您会发现其中有一节介绍如何删除验证规则 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.