If you defined function beforeSave() in your controller then essentially you are overriding the beforeSave function defined in AppController and its parent Controller.
So by calling parent::beforeSave() you are telling, you want to call the beforeSave method of the parent class which AppController. Ketan Brian wrote: > Ah, I see now. Thanks for spelling that out for me. It works quite > well :) > > So parent::beforeSave() essentially tells the model to use the > beforeSave callback? > Walker Hamilton wrote: > > function beforeSave() > > { > > > > if(isset($this->data['ItemData']['common_name'])) > > $this->data['Item']['name'] = $this->data['ItemData']['common_name']; > > > > return parent::beforeSave(); > > } > > > > > > > > On Jul 5, 12:54 pm, Brian <[EMAIL PROTECTED]> wrote: > > > I'm still a little confused. > > > > > > So I keep what I have right now ($this->data[....) in my beforeSave() > > > and then do what? > > > > > > Walker Hamilton wrote: > > > > you shouldn't need to create a hidden field called 'name'. > > > > > > > just do the assignation in beforeSave. > > > > > > > you need to make sure your beforeSave in the model returns > > > > parent::beforeSave > > > > > > > On Jul 5, 12:19 pm, Brian <[EMAIL PROTECTED]> wrote: > > > > > Here's a quick synopsis of the scenario: There's a menu, which has > > > > > items, and these have a name and price. I also have a table in a > > > > > separate database that has a ton of information on every item. I've > > > > > got an AutoCompleter set up with this third table(ItemData, field > > > > > 'common_name') and what I would like to do is take whatever value is > > > > > in the AutoCompleted input field when the form is submitted and treat > > > > > it as the 'name' property for the Item. > > > > > > > > My initial thought was to use the beforeSave() function in my Item > > > > > model with something like this: > > > > > > > > $this->data['Item']['name'] = $this->data['ItemData']['common_name']; > > > > > > > > I made a hidden field with the name attribute as "data[Item][name]" > > > > > but it doesn't work. Anyone else done something like this? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---