Zend_Form_Element_MultiSelect element definition

Ris90 picture Ris90 · Aug 15, 2010 · Viewed 7.2k times · Source

Is there any way to define which options in Zend_Form_Element_MultiSelect would be selected by default?

Answer

Keyne Viana picture Keyne Viana · Aug 15, 2010
  $element = new Zend_Form_Element_MultiCheckbox('foo', array(
      'multiOptions' => array(
          'foo' => 'Foo Option',
          'bar' => 'Bar Option',
          'baz' => 'Baz Option',
          'bat' => 'Bat Option',
    );
  ));
  $element->setValue(array('bar', 'bat'));

http://framework.zend.com/manual/en/zend.form.standardElements.html#zend.form.standardElements.multiCheckbox