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.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.