Thanks, that worked, but now I get other errors about undefined
indexes and undefined variables... Looking at my code it doesn't
really make sense either. Maybe the example I found isn't really
suitable for what I'm trying to achieve?
In my app, a post can belong to one category, and I want to list all
categories in a dropdown, with the current category selected.
This is the code now:
function edit($id = null)
{
if (empty($this->data))
{
//getting the categories
$categories = $this->Post->Category->findAll();
foreach($categories as $pass)
{
foreach ($pass as $key => $value)
{
$cats[$value['id']] = $value['title'];
if ($value['id'] ===
$data['post']['category_id']) // where does
the $cats array come from?
{
$catselected = $value['id'];
} //end if
} //end foreach
} //end foreach
$this->set('cats', $cats);
$this->set('catselected', $catselected);
}
else
{
//...
}
On 13 mrt, 11:13, "Dr. Tarique Sani" <[EMAIL PROTECTED]> wrote:
> On 3/13/07, gerbenzomp <[EMAIL PROTECTED]> wrote:
>
> > foreach ($this->model['post']->category->findAll() as $pass)
>
> Try
>
> $categories = $this->Post->Category->findAll();
> foreach($categories as $pass)
>
> HTH
> Tarique
>
> --
> =============================================================
> PHP for E-Biz:http://sanisoft.com
> Cheesecake-Photoblog:http://cheesecake-photoblog.org
> =============================================================
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---