I have a radio element with two options. I want to set one as the default value in case the user forgets to check it. How can I do this?
$this->addElement('radio', 'choose', array(
'required' => true,
'multiOptions' => array(
'yes' => 'heck yes',
'no' => 'please no'
),
'value' => 'yes' //key of multiOption
));
use setValue with key. For example:
$enablestate=new Zend_Form_Element_Radio('enablestate');
$enablestate->addMultiOptions(array('enabled'=>'Enabled','unenabled'=>'Unenabled'));
$enablestate->setSeparator('')->setValue('enabled');
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