سؤال

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");
هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top