Reputation: 29
I want unset validate rules in beforValidate but I have notices:
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?
Upvotes: 1
Views: 4636
Reputation: 29121
First step is to usually try the Amazing Online CakePHP Book.
If you do that, you'll notice there's a section on how to remove validation rules.
Upvotes: 7