Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zend Form Radio Default Checked

I have the next radio button group:

$enabled = $this->createElement('radio', 'enabled')
                ->setLabel('Enabled')
                ->setMultiOptions(array('1'=>'yes', '0'=>'no'))
                ->setValue($rank_values['enabled'])
                ->setAttrib('id', 'enabled')
                ->setAttrib('class', $action . '_enabled')
                ->setSeparator('');

How can I set a checked radio? Now, when I open my script, there are not selected radio. I want to select 'yes'. How?

Thank you.

like image 912
Alex Pliutau Avatar asked Nov 28 '22 04:11

Alex Pliutau


1 Answers

it is much more easier :)

$enabled = $this->createElement('radio', 'enabled')
                ->setLabel('Enabled')
                ->setMultiOptions(array('1'=>'yes', '0'=>'no'))
                ->setValue($rank_values['enabled'])
                ->setAttrib('id', 'enabled')
                ->setAttrib('class', $action . '_enabled')
                ->setSeparator('')
                ->setValue("1");
like image 141
Fribu - Smart Solutions Avatar answered Dec 06 '22 06:12

Fribu - Smart Solutions