从zend的多选项表单中获取值


Get value from multioptions form in zend

假设我有一个表单的子表单:

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

如何从multiOptions获得值?我设法得到数组使用,

$subForm = $form->getElement("foo");

您可以使用如下所示的getMultiOptions()getMultiOption()方法。

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

您可以在下面的ZF文档链接中找到更多方法。

ZF多选