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
+
0
-

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
+
0
-

Please move this topic to Bug Reports.

David Grudl
Nette Core | 8228
+
0
-

Js or PHP validation?

radas
Člen | 225
+
0
-

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)

David Grudl
Nette Core | 8228
+
0
-

Fixed