On Apr 13, 7:03 am, "ifcanduela" <[EMAIL PROTECTED]> wrote:
This is my add function, almost straight from the blog tutorial:
>
>     function add($region_id = null)
>     {
>         if (!empty($this->data))
>         {
>             $this->set('region_id' . $region_id);
>             if ($this->Country->save($this->data))
>             {
>                 $this->flash('New country added.', '/countries', 2);
>             }
>         }
>     }
>
> and I've written this in the view:
>
>     echo $html->hidden('Country/region_id', array( 'value' =>
> $region_id))
>
> However the variable isn't defined and I can't use it in the form.
>
> Anybody can help me?

You're close - try making the following line:
  $this->set('region_id' . $region_id);
to the first of your function.  You're only setting $region_id in the
view when (!empty($this->data)).  This is only true once the blank
form has been filled in and submitted, so the first time Cake
generates your blank form $region_id is not being set.


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