As you're after Program.name as your group value you need to contain
your Program model.
By default for recursive when using find('list') is set to -1 to be
sure to include recursive=>1 too.
HTH, Paul
Reference:
http://groups.google.com/group/cake-php/browse_thread/thread/3cf1fc29ba8942bd
On Oct 18, 4:40 pm, rockbust <[email protected]> wrote:
> Having trouble assigning a label to an optgroup.
>
> my controller
> $ranks = $this->Rankforuser->Rank->find('list', array( 'fields' =>
> array('Rank.id', 'Rank.rank_name','Rank.program_id'), 'order' =>
> array('Rank.sort_id' => 'ASC') ));
> debug($ranks);
> $programs = $this->Rankforuser->Program->find('list');
>
> produces:
> Array
> (
> [1] => Array
> (
> [1] => White Belt
> [2] => Yellow Belt
> [4] => Green Belt
> )
>
> [2] => Array
> (
> [27] => White Belt
> [25] => Dragon White Belt
> [26] => Dragon Yellow Belt
> )
>
> )
>
> would like it to produce:
> Array
> (
> [taekwondo] => Array
> (
> [1] => White Belt
> [2] => Yellow Belt
> [4] => Green Belt
> )
>
> [kungfu] => Array
> (
> [27] => White Belt
> [25] => Dragon White Belt
> [26] => Dragon Yellow Belt
> )
>
> )
>
> my view
> echo $this->Form->input('rank_id');
>
> is there some way to achieve this with the database call or in the
> view with the input formatting?
> or do I need to restructure the array then pass it to the view?
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php