在 zend 2 表单的复选框元素中设置默认值 'SELECTED'

setting default 'SELECTED' in checkbox elements of zend 2 forms

我想在 zend 2 中为我的复选框设置默认 'selected'

我尝试添加默认值

'value'=>'selected'

但是好像不行。

$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',
                ),
            ),    

        ));

该值应该是 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',
    ),
));