Question

Let's suppose that I have this subform of a form:

$form->addElement('select','foo',
array(
    'label'        => 'ComboBox (select)',
    'value'        => 'blue',
    'multiOptions' => array(
        'red'    => 'Rouge',
        'blue'   => 'Bleu',
        'white'  => 'Blanc',
    ),
    )
);

How do I get the value from multiOptions? I managed to get the array using,

$subForm = $form->getElement("foo");
Was it helpful?

Solution

You can use the getMultiOptions() and getMultiOption() methods as shown below.

$form->getElement("foo")->getMultiOptions(); //Get all options

$form->getElement("foo")->getMultiOption('option'); //Get one option.

You can find more methods in the ZF documentation link below.

ZF Multi select

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top