-1
为什么选择Zend \ Form \ Element \ Select中的空项目也被选为零元素?Zend Framework 2:选择元素 - 空选项
在窗体类:
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'name' => 'active',
'options' => array(
'label' => _('Active'),
'empty_option' => '',
'value_options' => array(
1 => 'Yes',
0 => 'No',
),
),
));
在控制器:
$searchForm->setData($request->getPost());
HTML,产生ZF2:
<select name="active">
<option value="" selected="selected"></option>
<option value="1">Yes</option>
<option value="0" selected="selected">No</option>
</select>
谢谢。我也认为这是错误。我在github上就这个问题开了一个问题:https://github.com/zendframework/zf2/issues/3426 – Eremite