I've only just noticed that there is indeed a group parameter for
Set::combine(). So you could quite easily do

$people = $this->Person->find(
  'all',
  array(
    'conditions' =>array('Hobby.name' => $keywords),
    'recursive' => 0
  )
);

$placesList = Set::combine($people, '{n}.Place.id', '{n}.Place.name',
'{n}.Place.state');

Still, no counts without post-processing though.

On Dec 7, 2:49 pm, djiize <[EMAIL PROTECTED]> wrote:
> there is an argument for generateList that group your result by state:
> $places_list    = $this->Hobby->Place->generateList(null, 'name ASC',
> null, null, null, '{n}.Place.state');
>
> and with a little post-processing, you'll have counts:
> foreach ($places_list as $state => $places) {
>   foreach ($places as $place_id => $place) {
>     $count = $this->Hobby->Person->findCount(array('place_id' =>
> $place_id));
>     $places_list[$state][$place_id] = $places_list[$state]
> [$place_id] . ' (' . $count . ')';
>   }}
>
> $this->set('places', $places_list);
>
> and in you view:
> <?php echo $form->input('Place.id', array('options' => $places,
> 'empty' => 'Choose a place')) ?>
--~--~---------~--~----~------------~-------~--~----~
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