Assuming you have set up Category belongsTo CategoryGroup, it's as
easy as :

(controller)
$tmp = $this->Category->find('all', array(
  'fields' => array('Category.id', 'Category.name',
'CategoryGroup.name'),
  'recursive' => 0,
  'order' => 'CategoryGroup.name ASC, Category.name ASC'
));
$categories = Set::combine(
  $tmp,
  '{n}.Category.id',
  array(
    '%s -> %s',
    '{n}.CategoryGroup.name',
    '{n}.Category.name'
  )
);
$this->set(compact('categories'));

(view)
echo $form->input('Category.Category');
// (FormHandler's magic will generate a multiple select box populated
with the $categories variable. The HABTM association will ensure the
correct items are selected. Pure magic.)

On Jun 2, 6:04 am, Leandro Ardissone <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have 3 tables:
> -Movies
> -Categories
> -CategoryGroup
>
> And I want to display a SELECT field on the Movies.add form, that
> shows as label: "CategoryGroup.name -> Category.name" for each value.
>
> Now I'm using HABTM to get the Categories ID's in that SELECT field.
> But I can't figure how to get that other table joined and display the
> groupcategory names in the categories select box.
>
> An idea?
>
> Thanks,
> Leandro
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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