How work the method prepareSave?

Hello good day. I need to add validations in my model. How will the new function work?

edited May '16

Just read the docs next time. For model validation you should use validation method - https://docs.phalconphp.com/pl/latest/reference/models.html#validating-data-integrity.

It will be fired on save method(create/update).

Keep in mind that in 2.1.x validation will change a bit.

https://blog.phalconphp.com/post/phalcon-2-1-beta-released



31.5k
edited May '16

Hi. I already updated. And add the following lines

use Phalcon\Validation;
use Phalcon\Mvc\Model\Validator\Email as EmailValidator;
use Phalcon\Mvc\Model\Validator\Uniqueness as UniquenessValidator;


public function validation()
{
    $this->validate(
        new UniquenessValidator(
            [
                'field'   => 'CONT_CEDULA',
                'message' => 'Sorry, That username is already taken',
            ]
        )
    );

    if ($this->validationHasFailed() == true) {
        return false;
    }
}

But he stays on a white screen does not work

This mean you have exception, just check logs...



31.5k

I did not know there were logs How do I check the logs ?. I reviewed the variables in the web browser.

I mean PHP LOGS, white page = means exception, it's not related to phalcon itself, it's related to php, why you are starting working with framework without any knowledge about php ?