Skip to content

Commit

Permalink
Fix validation of CheckboxList; version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Robyer authored Sep 28, 2016
1 parent 90e1522 commit 80e6721
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion live-form-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Live Form Validation for Nette Forms 2.4
*
* @author Robert Pösel, zakrava, Radek Ježdík, MartyIX, David Grudl
* @version 1.8.0
* @version 1.8.1
* @url https://github.com/Robyer/nette-live-form-validation/
*/

Expand Down Expand Up @@ -506,6 +506,12 @@ Nette.getEffectiveValue = function(elem) {
* Validates form element against given rules.
*/
Nette.validateControl = function(elem, rules, onlyCheck, value, emptyOptional) {
// LiveForm: addition
// Fix for CheckboxList - validation rules are present always only on first input
if (elem.name && elem.name.match(/\[\]$/) && elem.type.toLowerCase() == 'checkbox') {
elem = elem.form.elements[elem.name].tagName ? elem : elem.form.elements[elem.name][0];
}

elem = elem.tagName ? elem : elem[0]; // RadioNodeList
rules = rules || Nette.parseJSON(elem.getAttribute('data-nette-rules'));
value = value === undefined ? {value: Nette.getEffectiveValue(elem)} : value;
Expand Down

0 comments on commit 80e6721

Please sign in to comment.