Skip to content
This repository was archived by the owner on May 24, 2018. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/languages/en/modules/zend.form.element.checkbox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,31 @@ Using the array notation:
));


When creating a checkbox element, setting an attribute of checked will result in the checkbox always being checked
regardless of any data object which might subsequently be bound to the form. The correct way to set the default value
of a checkbox is to set the value attribute as for any other element. To have a checkbox checked by default make the
value equal to the checked_value eg:

.. code-block:: php
:linenos:

use Zend\Form\Form;

$form = new Form('my-form');
$form->add(array(
'type' => 'Zend\Form\Element\Checkbox',
'name' => 'checkbox',
'options' => array(
'label' => 'A checkbox',
'use_hidden_element' => true,
'checked_value' => 'yes',
'unchecked_value' => 'no'
),
'attributes' => array(
'value' => 'yes'
)
));

.. _zend.form.element.checkbox.methods:

.. rubric:: Public Methods
Expand Down