如何用$this-> formSelect()创建这个?
<select multiple> <optgroup label="a"> <option>1</option> <option>2</option> </optgroup> <optgroup label="b"> <option>1</option> </optgroup> </select>
对于Zend_Form_Element_Select(),它就像这样
$multiOptions = array( 'Group A' => array(1 => 'First Value',2 => 'Second Value A),'Group B' => array(3 => 'Third Value'),); $element->setMultiOptions($multiOptions);
请注意,您还有addMultiOption($option,$value)和addMultiOptions($options).只需将值或选项添加到附加数组中即可.