Thx for pointing out Mariano.. I understand that only controllers have actions not Models.. I was even thinking of writing a function in the model for this Model..
if id is empty then its add - Brilliant One Mate !! just wanted this functionality.. And I am new to CakePHP and loving it as a framework..and moving loads of php only sites to this framework.. On Mar 25, 7:10 pm, "Mariano Iglesias" <[EMAIL PROTECTED]> wrote: > I think you have your concepts mixed up. Read over the three basic elements > of an MVC framework: > > Controllers:http://manual.cakephp.org/chapter/controllers > Models:http://manual.cakephp.org/chapter/models > Views:http://manual.cakephp.org/chapter/views > > Controllers have $action, not models. > > The way to do your thing would be: > > function beforeSave() > { > if (empty($this->id)) > { > // Adding (not editing) > } > > return parent::beforeSave(); > > } > > -MI > > --------------------------------------------------------------------------- > > Remember, smart coders answer ten questions for every question they ask. > So be smart, be cool, and share your knowledge. > > BAKE ON! > > blog:http://www.MarianoIglesias.com.ar > > -----Mensaje original----- > De: [email protected] [mailto:[EMAIL PROTECTED] En nombre > de varunkrish > Enviado el: Domingo, 25 de Marzo de 2007 08:57 a.m. > Para: Cake PHP > Asunto: re:use beforeSave only in add action > > function beforeSave() > { > if($this->data){ > if($this->action=="add"){ > //load stuff > } > > } > > this throws Notice: Undefined property: Product::$action --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---
