Re: Controller, Add Method.. setting default values..

2008-02-15 Thread Dardo Sordi Bogado
Nice one! On Fri, Feb 15, 2008 at 3:49 PM, francky06l <[EMAIL PROTECTED]> wrote: > > If you define some default value in the database definition (not null > and a default), you can call $this->data = $this->Expense->create() in > controller prior to render the view. The default value defined i

Re: Controller, Add Method.. setting default values..

2008-02-15 Thread francky06l
If you define some default value in the database definition (not null and a default), you can call $this->data = $this->Expense->create() in controller prior to render the view. The default value defined in the table will be used. hth On Feb 15, 6:14 am, duncan_m <[EMAIL PROTECTED]> wrote: > Than

Re: Controller, Add Method.. setting default values..

2008-02-14 Thread duncan_m
Thanks.. I had a typo.. its working now :) I see that the view would be a better place for the logic. Thanks for that hint. Duncan. On Feb 15, 1:29 pm, Adam Royle <[EMAIL PROTECTED]> wrote: > This works for me in latest 1.2. > > However, maybe this logic should be in your view?? > > echo $form-

Re: Controller, Add Method.. setting default values..

2008-02-14 Thread Novice Programmer
you are checking *if (empty($this->data))* is there some other data that is coming from the view(such as some other fields in the form) for you except these default fields. if there is some other data coming as well then $this->data wont be empty and hence your default values wont be populated.. it

Re: Controller, Add Method.. setting default values..

2008-02-14 Thread Adam Royle
This works for me in latest 1.2. However, maybe this logic should be in your view?? echo $form->input('anotherfield', array('default' => 'A default value')); Cheers, Adam On Feb 15, 12:03 pm, duncan_m <[EMAIL PROTECTED]> wrote: > Hi there, > > I guess I'm just not understanding fundamental...

Re: Controller, Add Method.. setting default values..

2008-02-14 Thread b logica
On Thu, Feb 14, 2008 at 9:03 PM, duncan_m <[EMAIL PROTECTED]> wrote: > > Hi there, > > I guess I'm just not understanding fundamental... > > I have a simple controller with Baked methods for adding, editing > etc.. I'm trying to modify the behaviour, when the add() method is > invoked I want

Controller, Add Method.. setting default values..

2008-02-14 Thread duncan_m
Hi there, I guess I'm just not understanding fundamental... I have a simple controller with Baked methods for adding, editing etc.. I'm trying to modify the behaviour, when the add() method is invoked I want to populate a few default values for a couple of the fields.. My code currently looks li