Thanks guys. I dont know why I was adding it to the controller :( But it works as it should.
Thanks for your time and patience. Dave On Nov 19, 4:27 am, David Roda <[email protected]> wrote: > No problem, I am not sure the OP has it in his model though > > On Thu, Nov 19, 2009 at 2:21 AM, jburns <[email protected]> wrote: > > My apologies - I meant model but typed controller inadvertently. > > > On Nov 19, 7:18 am, David Roda <[email protected]> wrote: > > > beforeSave is a model callback, not a controller call back. It needs to > > go > > > into your model > > > > On Wed, Nov 18, 2009 at 11:06 PM, jburns <[email protected]> wrote: > > > > Whenever I have used beforeSave in a controller (not sure if you are > > > > using this in AppController?) I have called parent::beforeSave(); > > > > first. Really don't know if that will make a difference or not. > > > > > On Nov 19, 4:02 am, Dave <[email protected]> wrote: > > > > > Ok now I have > > > > > > function beforeSave() > > > > > { > > > > > > return false; > > > > > } > > > > > > so it should fail automatically but it still saves. There has to be > > > > > something very wrong. > > > > > > Any one have any ideas what so ever? This makes no sense what so > > ever. > > > > > > Dave > > > > > > On Nov 18, 9:05 pm, Dave <[email protected]> wrote: > > > > > > > I have : > > > > > > > function beforeSave() > > > > > > { > > > > > > App::import('Core', 'sanitize'); > > > > > > $this->data = Sanitize::clean($this->data); > > > > > > return true; > > > > > > } > > > > > > > But no matter what I save nothing happens to the data. > > > > > > > Even tried adding this to the before save > > > > > > > function beforeSave() > > > > > > { > > > > > > App::import('Core', 'sanitize'); > > > > > > $this->data = Sanitize::clean($this->data); > > > > > > > if(!empty($this->data)) > > > > > > { > > > > > > $this->data['Award']['title'] = 'added from > > > > beforeSave'; > > > > > > > } > > > > > > return true; > > > > > > } > > > > > > > But still nothing. > > > > > > > Any ideas anyone? > > > > > > > On Nov 18, 2:40 am, Erik Nedwidek <[email protected]> > > wrote: > > > > > > > > Dave, > > > > > > > > No need to call the beforeSave method as it is a callback. > > > > > > > > function beforeSave() { > > > > > > > App::import('Sanitize'); > > > > > > > $this->data = Sanitize::clean($this->data); > > > > > > > > return true; > > > > > > > > } > > > > > > > > That should be all you need to do. Throw a couple of $this->log() > > > > statements > > > > > > > in there to verify the method is being called by Cake if you're > > not > > > > sure. > > > > > > > > Erik Nedwidek > > > > > > > Project Manager > > > > > > > Lighthouse I.T. Consulting, Inc. > > > > > > > > On Tue, Nov 17, 2009 at 10:37 PM, Dave <[email protected] > > > > > wrote: > > > > > > > > Do you manually have to call beforeSave(); > > > > > > > > > I have > > > > > > > > function beforeSave() > > > > > > > > { > > > > > > > > $clean = new Sanitize(); > > > > > > > > $this->data = $clean->clean($this->data); > > > > > > > > return true; > > > > > > > > > } > > > > > > > > > But it does nothing to the data. > > > > > > > > > What am I doing wrong? > > > > > > > > > Dave > > > > > > > > > -- > > > > > > > > > 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]<cake-php%[email protected]> > > <cake-php%[email protected] om> > > > > <cake-php%[email protected] om> > > > > > > > > . > > > > > > > > For more options, visit this group at > > > > > > > >http://groups.google.com/group/cake-php?hl=. > > > > > -- > > > > > 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]<cake-php%[email protected]> > > <cake-php%[email protected] om> > > > > . > > > > For more options, visit this group at > > > >http://groups.google.com/group/cake-php?hl=. > > > -- > > > 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]<cake-php%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/cake-php?hl=. > > -- 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=.
