Checkbox and radio
Checkbox
Checkbox by itself is not commonly used. Some use case can be remember me
checkbox on login:
<?php
$this->add('remember_me', 'checkbox', [
'value' => 1,
'checked' => true
]);
Beside inherited, there are 2 more options:
value
(String) (Default:null
) - value that will be used for the value attributechecked
(Boolean) (Default:false
) - If true, checkbox will be checked
<div class="form-group">
<input type="checkbox" value="1" checked id="remember_me" name="remember_me">
<label for="remember_me">Remember me</label>
</div>
Radio
Radio is also not commonly used in this way, even less than checkbox, because it creates only single radio button.
<?php
$this->add('remember_me', 'radio', [
'value' => 1,
'checked' => false
]);
Beside inherited, there are 2 more options:
value
- value that will be used for the value attributechecked
- If true, checkbox will be checked. Default:false
<div class="form-group">
<input type="radio" value="1" checked id="remember_me" name="remember_me">
<label for="remember_me">Remember me</label>
</div>