summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2017-07-28 16:14:53 +0200
committerJo-Philipp Wich <jo@mein.io>2017-07-28 16:14:53 +0200
commit4c9ae3f615fb85a888728c251568259fb82246a2 (patch)
treedc68407586c36fc7ccfacba680236572064759d6 /modules/luci-base
parent4201282559d85988990c8f48f4075bed5f785c2f (diff)
luci-base: cbi.js: fix handling of inverse-depends, combobox validation
- Properly handle logic for evaluating inverted dependencies means when depending on another field *not* having a given value - Perform datatype validation *after* populating combobox choices to avoid triggering a false-positive when validating an .rmempty = false combobox during form instantiation Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index 4be917d09..b819230cf 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -481,8 +481,9 @@ function cbi_d_check(deps) {
istat = (istat && cbi_d_checkvalue(j, deps[i][j]))
}
}
- if (istat) {
- return !reverse;
+
+ if (istat ^ reverse) {
+ return true;
}
}
return def;
@@ -648,9 +649,6 @@ function cbi_combobox(id, values, def, man, focus) {
var dt = obj.getAttribute('cbi_datatype');
var op = obj.getAttribute('cbi_optional');
- if (dt)
- cbi_validate_field(sel, op == 'true', dt);
-
if (!values[obj.value]) {
if (obj.value == "") {
var optdef = document.createElement("option");
@@ -685,6 +683,9 @@ function cbi_combobox(id, values, def, man, focus) {
obj.style.display = "none";
+ if (dt)
+ cbi_validate_field(sel, op == 'true', dt);
+
cbi_bind(sel, "change", function() {
if (sel.selectedIndex == sel.options.length - 1) {
obj.style.display = "inline";