Stark
Stark

Reputation: 65

How i can get the error when cake are saving?

I have a form, with some fields. When i try save, not happens and I don´t know what´s the problem. How can i see whats happening on the save moment ?!

Thanks you!.

Upvotes: 0

Views: 278

Answers (2)

Justin T.
Justin T.

Reputation: 3701

Anywhere in your view file, you get the errors like this :

<?php debug($this->AnyModel->validationErrors);?>

Aside from debugging, you display field-by-field error like this :

<?php $this->Form->error('fieldname'); ?>

This will return the message from validation rules, only if the field has thrown an error.

Hope this helps!

Upvotes: 1

ADmad
ADmad

Reputation: 8100

These are the most likely causes for a failed save:

  • incorrect data array structure, debug data passed for saving
  • failing validation, debug($this->SomeModel->validationErrors) after save
  • beforeSave/beforeValidate callback in model or attached behavior not returning true
  • sql error, turn up debug to 2

Upvotes: 3

Related Questions