1

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?

Piotr
  • 29
  • 2
  • 8
  • There's something wrong with your model, you'll only receive such a message in case there is no `$validate` property. http://stackoverflow.com/q/19716393/1392379 ps, please always mention your exact CakePHP version! – ndm Nov 10 '13 at 16:58

1 Answers1

7

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.

Dave
  • 28,833
  • 23
  • 113
  • 183