Why does `cake bake` have that reversed? $this->Model->create(); //empty $this->Model->save($this->data); //filled with sent data
?? Also, is Daniel trying to update the found model (if found), or create a new model? I don't understand the reason for calling $this->Model- >findById($id); in this instance. I have a feeling that Jon was assuming an additional record created from already existing data within a different record (i.e.: copy), but is that correct? On Apr 29, 6:58 am, Jon Bennett <[email protected]> wrote: > Hi Daniel, > > > I´m sure that $this->data['MyModel']['created'] is not set. > > In your example you were not resetting the created or modified values. > > > And the function create() resets any data setted in Model. > > Yes and no. If you're creating a record, you should pass > $this->Model->create($data); your data, which internally resets any > behaviours, calls validation and sets the data in teh model. > You then simply call $this->Model->save(); without any params to save. > If you're updating a record, you should call $this->Model->set($data); > before save, which does the same thing. IMO the docs are a little > misleading on this point (not read up on create/set/save for a long > long time!). > > When copying existing records, it's always advisable to explicitly > reset any values you want to revert to defaults, unless you've > explicitly not included those fields in the find()/read(). > > hth > > Jon > > -- > > jon bennett > w:http://www.jben.net/ > iChat (AIM): jbendotnet Skype: jon-bennett --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---
