On a normal select, with no optgroups, the following code in CakePHP would make a value the default one:
'selected' => $value
Once I have optgroups (a select tag with headings) how do I set a default value? The previous code doesn't seem to work.
you might try it like this:
echo $this->Form->input('group_id', array('type'=>'select','default'=>'2'));
leading to the following HTML being generated:
<option value="2" selected="selected">Managers</option>
Now option two is shown instead any other one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With