如何在zend框架2中使用表单选择元素的选定选项?

时间:2013-06-21 16:45:58

标签: php zend-framework

我正在使用Zend \ Form \ View \ Helper \ FormSelect,但我没有找到在select元素中设置所选值的方法。

$countryList = array_merge (array('empty_option' => 'Please choose...'),     
$this->common()->getCountryList() );
$country->setValueOptions($countryList);
$country->setValue(array('AT' => 'AUSTRIA'));
echo $this->formSelect($country);

1 个答案:

答案 0 :(得分:1)

$country->setValue('AT');
As above, you can use setValue() for making 'AT' as selected.