Cakephp-create a multi select form field
13,536
In your ctp file:
echo $this->Form->input('Category', array(
'multiple' => 'multiple',
'type' => 'select',
));
in your action:
$cats = $this->Category->find('all');
foreach ($cats as $category) {
$categories[$category['Category']['id']] = $category['Category']['title'];
}
$this->set(compact('categories'));
Comments
-
huzefam almost 2 years
I need to create a multi select form field using form helpers in cakephp.The values in the field will get populated from a table which had got a HABTM to the current model.
What is the best way to implement this?