How to get the validation errors from a Model on the controller – Cakephp

Is quite simple actually,

// validate if data in correct format
$this->data = $this->Model->validateUserForm($this->data, $id);
$errors = $this->Model->invalidFields();
$this->set(compact($errors));

It will return an array where the keys are the field names and the values are actually the errors for that field names.

Have fun.

 

 

Advertisements

About mcloide

Making things simpler, just check: http://www.mcloide.com View all posts by mcloide

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: