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 would be better to install the logic
as:

if ($this->data['Expense']['SomeField'] == '') {
               $this->data['Expense']['SomeField'] = 'A Default Value';
}

I hope i were clear.

Thanks.



On 2/15/08, Adam Royle <[EMAIL PROTECTED]> wrote:
>
>
> 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...
> >
> > 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 like this:
> >
> > function add($resSomeIntegerValue) {
> >                 if (empty($this->data)) {
> >                         $this->data['Expense']['SomeField'] =
> $resSomeIntegerValue;
> >                         $this->data['Expense']['AnotherField'] = 'A
> Default Value';
> >                         $this->render();
> >
> > As you can see I've added two lines to set up 2 fields with the values
> > I want as a default when calling this method. The view, when it
> > renders, doesn't have these default values displayed..
> >
> > Any help much appreciated.
> >
> > With thanks,
> >
> > Duncan.
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to