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

If you're not using those fields for your other views (or having these
values in those fields wouldn't make a difference in other views) you
could do this in the model's afterFind().

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