Thursday, December 30, 2010

Re: Controller->save() fails

On Thu, Dec 30, 2010 at 12:00 PM, TOm W <tom.wurdock@gmail.com> wrote:
>>   If Controller->save($this->data) fails, how can I determine what happened?
>
> I meant Model->save() fails...

First, make sure debug is set to 2 in core.php. Then make sure you're
not redirecting if save does not succeed. In most cases, if set up
correctly, FormHelper will display an error below the element in
question. But you can also check the controller's $validationErrors. A
quick way to do that:

$this->YourModel->set($this->data);

if ($this->YourModel->validates())
{
...
}
else
{
die(debug($this->validationErrors));
}

But you also need to look at the model's $validate array, if it
exists. Perhaps one of the rules isn't correct.

http://book.cakephp.org/view/1182/Validating-Data-from-the-Controller

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: