ZendFramework - How to create optgroup and there option using view helpers?
问题 How do i create this with $this->formSelect() ? <select multiple> <optgroup label="a"> <option>1</option> <option>2</option> </optgroup> <optgroup label="b"> <option>1</option> </optgroup> </select> 回答1: For the Zend_Form_Element_Select() it goes like this $multiOptions = array( 'Group A' => array(1 => 'First Value',2 => 'Second Value A), 'Group B' => array(3 => 'Third Value'), ); $element->setMultiOptions($multiOptions); Note that you also have addMultiOption($option,$value) and