beforeValidate() seems to be a nice place then because validation might reject the values that i want to modify later on. Am i correct?
Thanks. On 2/5/08, nate <[EMAIL PROTECTED]> wrote: > > > Not true actually. Generally speaking, any time you *can* put logic > in the model, you should. Don't move it out into the controller > unless it is necessary for some reason. > > On Feb 4, 11:14 pm, manish <[EMAIL PROTECTED]> wrote: > > I think, The best way to do this stuff is in the controller itself. > > > > First you need to check whether the data is posted from the form. > > You can do so by doing something like: > > > > if(!empty($this->data['ModelName']['id'])) > > > > if it is so, you can check: > > > > if(empty($this->data['ModelName']['title'])) > > $this->data['ModelName']['title'] = "Your_Custom_Title"; > > > > Hope this helps. > > > > On Feb 5, 7:48 am, "Novice Programmer" <[EMAIL PROTECTED]> > > wrote: > > > > > Hello guys, > > > > > I was wondering that what is the best place to change the data to be > fed to > > > the model. Consider the following situation: > > > > > I have a form which asks the user about the title of a content. if the > user > > > has not given the title, i want to give some default value to the > title(note > > > that this default value is dynamic and called be defined using default > > > directive in MySql). > > > > > Now what is the best place to do this stuff? is it beforeValidate or > > > beforeSave or should i modify the data in the controller itself? > > > > > -- > > > Thanks & Regards, > > > Novice (http://ishuonweb.wordpress.com/). > > > -- Thanks & Regards, Novice (http://ishuonweb.wordpress.com/). --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
