addCheckboxList() and setRequired() requires always the first item
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- radas
- Člen | 225
An example from Nette 2.1:
$form->addCheckboxList('colors', 'Favorite colors:', array(
'r' => 'red',
'g' => 'green',
'b' => 'blue',
))
->setRequired();
Validation requires always the first item to be checked.
When I use $form->addRadioList(), I can select any item and form is valid.
Editoval radas (6. 1. 2014 16:17)
- radas
- Člen | 225
JS validation. When JS is enabled, the first item of checkboxlist is required. When JS is disabled, HTML5 validation is used and all items of checkboxlist are required. I don't know, how to check PHP validation without HTML5 validation.
I assumed, that setRequired() will require at least one item checked.
Editoval radas (6. 1. 2014 21:11)