我想为zend 2中的复选框设置默认'选中'。
我尝试添加默认
'值'=> '选择'
但它似乎不起作用。
$this->add(array(
'type' => 'Zend\Form\Element\Checkbox',
'name' => 'receiveNewsletters',
'options' => array(
'value_options' => array(
'1' => 'Untick if you do not want to receive promotional emails',
),
'attributes' => array(
'value'=>'selected',
),
),
));
答案 0 :(得分:0)
该值应为checked_value
。默认情况下为'1'
$this->add(array(
'type' => 'Zend\Form\Element\Checkbox',
'name' => 'receiveNewsletters',
'options' => array(
'label' => 'Untick if you do not want to receive promotional emails',
),
'attributes' => array(
'value' => '1',
),
));