CakePHP: Model save function returning false without an error or SQL statements

I recently was running into an issue where the function $this->User->save($this->data); was returning false without any indication of an error, and also there was no SQL statement in the debugging section.

With some help from this stack overflow post, I found the error by putting the following after the save function in my controller:

echo var_dump($this->User->invalidFields());

This allowed me to see that the form was invalid because of a missing field, a field which I forgot to include the HTML for in the view and therefore the error was not displaying.

4 responses to “CakePHP: Model save function returning false without an error or SQL statements”

  1. Jorge Gutierrez says:

    Thanks a lot …………………………………..

  2. Martti says:

    Thank you very much. This really saved my day!!! I have two login systems in my software (facebook and normal). I were struggling why save method returns false when I’m trying to save data my facebook user, but otherwise works perfectly. With var_dump($this->User->invalidFields()); I found out that there were error in email validation field. I didn’t even know that CakePHP validates User data again when I’m trying to add some data to different table, which relates to User.

    However this was easy to fix with adding false parameter in save methdod after data:


    False skips validation.

    And its all written in CakePHP book:

    Thanks again!

  3. Megga says:

    Thanks, helped save the day

  4. Honey says:

    Helped me a lot …..but wasted three hours for this problem

Leave a Reply

Your email address will not be published. Required fields are marked *