Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Do not change the password

Hi,

I have a problem about the password when I insert it into the database. I don't want to change the user's password if it's an update and if this password is null but if it's not null I want to insert it. I think I have to put this code in the function's model (BeforeValidationOnUpdate) but how I can assign the same password's value to validate the sha1 password ?



12.6k
Accepted
answer

Problem solved in this Thread.



32.7k

I had similar problems. See https://forum.phalconphp.com/discussion/863/skip-columns-on-validation-process . Unfortunately I ended up in creating a sepparately "change password form" that is handling this.

The best thing would be if they will add a skipColumn method. For now you can do that but onli on initialize(). The perfect way would be to have something like this:

public function beforeValidationOnUpdate()
{
    if (strlen($this->password) > 1) {
        $this->skipAttributes(
            array(
                'password'
            )
        );  
    }
}

+1 for this !