It might be a typo but you have a period instead of a comma on the
line

$this->set('region_id' . $region_id);


    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);
            }
        }
    }

On Apr 13, 7:03 am, "ifcanduela" <[EMAIL PROTECTED]> wrote:
> Hello, I'm new to CakePHP and have what I think is a very simple
> question, but I'm apparentyly unable to find a straight answer
> anywhere.
>
> I have a couple of MySQL tables, regions and countries, and I have
> already setup models, views and controllers for both of them, so I can
> display tables listing regions and I can click a region to see
> countries in that region. Everywhit working fine.
>
> I've placed an "add country" link in the country listing for each
> region, so that I can click the "add" link and enter a new country for
> the region.
>
> The problem is, I don't know how to pass the region_id to the country-
> add view, and when the country is inserted in the table it remains
> regionless. Since I know what the region_id is and I append it to the
> url (e.g. /cake/countries/add/8), I've tried to use set() to pass it
> to the view.
>
> 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 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