CakePHP model->save(): save all but some excluded fields

sacolunga

New Member
I want to save all but some excluded fields. I know that I can do it this way\[code\]$this->Blah->save($this->data,false,$fieldList)\[/code\]Where $fieldList contains all the data fields of the table but these I don't want to get saved. I have some tables that have maaany data fields, and I don't want to write the whole list from scratch in every single controller action (yes, the fields that should not be saved differ from action to action). Additionally, it looky messy and confusing. Is cakePHP providing something ready-to-use for this case? If not, I guess, I'd have to implement it by myself by adding a $fieldList property to every controller and doing something like this (ugly-hacked-together-solution):\[code\]$tmp = $fieldList;unset(array_search('fieldtoexclude', $tmp));$this->Blah->save($this->data,false,$tmp);\[/code\]Best Regards
 
Back
Top