Firstly, sorry for my English.
I would like to create a select input in CakePHP, who will have grouped the data.
Let's suppose I have some news in categories, I want to display it in the select input, that they are grouped by category, something like this:
== first category == (not clickable)
1 news of the first category
2 news of the first category
3 news of the first category
== Second category == (not clickable)
1 news of the second category
2 news of the second category
3 news of the second category
== third category == (not clickable)
[...]
etc.
Controller:
$this->set('news', $this->News->find('all',
array(
'CONTAIN' => array('News' => array('Category'))
'fields' => array('News.name', 'Category.name')
)));
View:
echo $this->form->input('news', array('options' => $news));
I have no idea how to create so grouped in a list. I tried using a parameter group, but nothing came.
At the moment it seems to me that would be some way to modify the $news as $options before displaying it in a view, but probably it is not the best solution.
I wonder whether there is possible to create appropriately grouped array in $news in the controller, or remain modification array before being displayed in the view.