Wednesday, July 28, 2010

Re: problem select menu with "optgroups"

On Wed, Jul 28, 2010 at 1:41 PM, hoss7 <hossbit@gmail.com> wrote:
> cricket how can i pass this array? (i am new in cakephp)
>

echo $form->select('category_id', $options);

I'm assuming here that the name should be 'category_id'.

You'll need to get the array into the proper format. You can probably
do that with the Set class but, otherwise, do something like:

$options = array();
foreach($data as $k => $v)
{
$cat_name = $v['Cat']['title'];

$options[$cat_name] = array();

foreach($v['Subcat'] as $sub_cat)
{
$options[$cat_name][$sub_cat['id']] = $sub_cat['title'];
}
}

$this->set(compact($options));

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate