Skip to content
Permalink
Browse files

netteForms: preventFiltering used for getEffectiveValue() instead of …

…validateRule() [Closes #161][Closes #143]

should be better solution than 94c47d5
  • Loading branch information...
dg committed Sep 29, 2019
1 parent 37a9490 commit c9e972ab50d8364c5d0045a53fa2a45f8f004520
Showing with 9 additions and 11 deletions.
  1. +9 −11 src/assets/netteForms.js
@@ -29,6 +29,7 @@
'use strict';

var Nette = {};
var preventFiltering = {};
var formToggles = {};

Nette.formErrors = [];
@@ -120,10 +121,12 @@
val = '';
}
}
if (filter) {
if (filter && preventFiltering[elem.name] === undefined) {
preventFiltering[elem.name] = true;
var ref = {value: val};
Nette.validateControl(elem, null, true, ref);
val = ref.value;
delete preventFiltering[elem.name];
}
return val;
};
@@ -297,8 +300,6 @@
};


var preventFiltering = false;

/**
* Validates single rule.
*/
@@ -312,16 +313,13 @@
op = op.replace(/\\/g, '');

var arr = Array.isArray(arg) ? arg.slice(0) : [arg];
if (!preventFiltering) {
preventFiltering = true;
for (var i = 0, len = arr.length; i < len; i++) {
if (arr[i] && arr[i].control) {
var control = elem.form.elements.namedItem(arr[i].control);
arr[i] = control === elem ? value.value : Nette.getEffectiveValue(control, true);
}
for (var i = 0, len = arr.length; i < len; i++) {
if (arr[i] && arr[i].control) {
var control = elem.form.elements.namedItem(arr[i].control);
arr[i] = control === elem ? value.value : Nette.getEffectiveValue(control, true);
}
preventFiltering = false;
}

return Nette.validators[op]
? Nette.validators[op](elem, Array.isArray(arg) ? arr : arr[0], value.value, value)
: null;

0 comments on commit c9e972a

Please sign in to comment.
You can’t perform that action at this time.