We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

save validate

Hi all How to remove validate when save $user = new Users(); $user->save(array( 'username' => 'admaaa', 'profilesId' => 1, 'email' => '[email protected]', )); User was created successfully, but $user = new Users(); $user->save(array( 'username' => 'admaaa', 'profilesId' => 1,

        ));

email is required , althought i not validate email in model, form....

Is the email field in your database set as NOT NULL? If so, Phalcon will validate the email as required implicitly.

To disable this behavior, should you choose, add this to your bootstrap:

\Phalcon\Mvc\Model::setup([
    'notNullValidations' => false
]);


58.4k

Hi Brian Seymour after setup \Phalcon\Mvc\Model::setup([ 'notNullValidations' => false ]); Integrity constraint violation: 1048 Column 'email' cannot be null

If that field must be set to not null, have a look at this post for a solution. https://forum.phalcon.io/discussion/747/what-is-the-correct-way-to-set-default-value-for-not-null-