How to indicate the specific fields to be saved or updated in CakePHP


If you want to save selected fields only to avoid validating the fields that are not included when you are going to save, do this.

Make an array that has the list of fields that is going to be saved
$fieldList = array(“p_address”,”p_age”);

Next pass the values of $fieldList in the save or saveAll method like this
$this->Person->saveAll($this->data,array(true,true,$fieldList))

That’s it. 🙂

Advertisements

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: