mercredi 16 décembre 2015

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

I want to set a default 'selected' for my checkbox in zend 2.

i tried adding a default

'value'=>'selected'

but it does not seem to work.

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

        ));




Aucun commentaire:

Enregistrer un commentaire