Set default radio button with Zend_Form_Element_Radio

Setting a default value (‘CHECKED’) in Zend_Form_Element_Radio is done with the function setValue(). This is an example of how to to this in Zend Framework 1.10

...
$typeOfLap = new Zend_Form_Element_Radio('typeoflap');
$typeOfLap->setRequired(true)
          ->addFilter('StripTags')
          ->addFilter('StringTrim')
          ->setDecorators(array('ViewHelper'))
          ->addMultiOptions(array(
               'Practice' => 'Practice',
               'Qualifying' => 'Qualifying'))
          ->setValue('Practice');
...

As most things in Zend this is also very simple.

Comments are closed.