简体   繁体   中英

Phalcon PHP: model validation() function?

In my model, I'm including the function validation(). It doesn't seem to be getting hit. I have something similar to this:

class People extends Phalcon\Mvc\Model {
    public function validation() {
        die('here');
    }
}

$person = new People();
$person->name = 'Bob';
$person->save();

But the validation function never gets called. Is there something I'm missing?

Thanks!

This method works only for existing model records.
If you want to validate on create, you could use beforeValidationOnCreate() method.
You can visit phalcon Documentation for all events.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM