Search code examples
selectzend-formoptgroup

zend framework - Remove optgroup from select box


In zend framework, how do you guys remove the optgroup from a select element?

Zend puts them by default but I don't want it.

I would think there would be an option like

array( 'optgroup' => false )


Solution

  • Dont't use the optgroup feature, see the 2 examples:

    $form = new Zend_Form();
    $form->addElement('select', 'city', array(
        'label' => 'Nested City List',
        'multiOptions' => array(
            'Jordan' => array(
                'ptr' => 'Petra',
                'amm' => 'Amman',
            ),
            'UAE' => array(
                'adb' => 'Abu Dhabi',
                'dub' => 'Dubai'
            )
        )
    ));
    
    
    $form->addElement('select', 'city2', array(
        'label' => 'Flat City List',
        'multiOptions' => array(
            'ptr' => 'Petra',
            'amm' => 'Amman',
            'adb' => 'Abu Dhabi',
            'dub' => 'Dubai'
        )
    ));