beforeValidation not called before internal validation on update
When a model is updated the beforeValidation method is not called prior to internal validation. Therefore, if a required field is not filled (or is filled with the wrong type), beforeValidation will never get called and the update fails immediately with the single internal message.
When a model is created, however, beforeValidation is called first.
Just to clarify, this happens in a very specific scenario:
class Test extends \Phalcon\Mvc\Model {
/**
* @Column(type="integer", nullable=false, length=1)
*/
$allow;
public function beforeValidation() {
echo "In beforeValidation";
}
}
$test = new Test();
$test->allow = 0; // This is the key, the value must be empty (i.e. 0, false, etc).
$test->create();
$test->assign(array('allow' => 'a'));
$test->update(); // beforeValidation not called
You could refresh the state of the model, by using $test->refresh();.
It should trigger again when trying to update.
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues
Thank you for contributing to this issue. As it has been 90 days since the last activity, we are automatically closing the issue. This is often because the request was already solved in some way and it just wasn't updated or it's no longer applicable. If that's not the case, please feel free to either reopen this issue or open a new one. We will be more than happy to look at it again! You can read more here: https://blog.phalconphp.com/post/github-closing-old-issues