Php 从zend中的多选项窗体获取值
假设我有一个表单的子表单:Php 从zend中的多选项窗体获取值,php,zend-framework,Php,Zend Framework,假设我有一个表单的子表单: $form->addElement('select','foo', array( 'label' => 'ComboBox (select)', 'value' => 'blue', 'multiOptions' => array( 'red' => 'Rouge', 'blue' => 'Bleu', 'white' =
$form->addElement('select','foo',
array(
'label' => 'ComboBox (select)',
'value' => 'blue',
'multiOptions' => array(
'red' => 'Rouge',
'blue' => 'Bleu',
'white' => 'Blanc',
),
)
);
如何从多选项中获取值?
我设法用
$subForm = $form->getElement("foo");
您可以使用getMultiOptions()
和getMultiOption()
方法,如下所示
$form->getElement("foo")->getMultiOptions(); //Get all options
$form->getElement("foo")->getMultiOption('option'); //Get one option.
您可以在下面的ZF文档链接中找到更多方法