Skip to content

Commit

Permalink
[bug-OpenMage#317] <depends> for multiselect fields not working corre…
Browse files Browse the repository at this point in the history
…ctly in admin panel

Fixes system config dependencies for multiselect fields
  • Loading branch information
sreichel authored and edannenberg committed Apr 1, 2019
1 parent 1c1537d commit b9d1b86
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions js/mage/adminhtml/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,19 @@ FormElementDependenceController.prototype = {
levels_up : 1 // how many levels up to travel when toggling element
},

getSelectValues : function(select) {
var result = [];
var options = select && select.options;
var opt;
for (var i = 0, iLen = options.length; i < iLen; i++) {
opt = options[i];
if (opt.selected) {
result.push(opt.value);
}
}
return result;
},

/**
* Define whether target element should be toggled and show/hide its row
*
Expand All @@ -529,13 +542,20 @@ FormElementDependenceController.prototype = {
var shouldShowUp = true;
for (var idFrom in valuesFrom) {
var from = $(idFrom);
if (valuesFrom[idFrom] instanceof Array) {
if (!from || valuesFrom[idFrom].indexOf(from.value) == -1) {
if (from.tagName === 'SELECT' && from.className.indexOf('multiselect') > -1) {
var elementValues = this.getSelectValues(from);
if (!from || elementValues.indexOf(valuesFrom[idFrom]) <= -1) {
shouldShowUp = false;
}
} else {
if (!from || from.value != valuesFrom[idFrom]) {
shouldShowUp = false;
if (valuesFrom[idFrom] instanceof Array) {
if (!from || valuesFrom[idFrom].indexOf(from.value) == -1) {
shouldShowUp = false;
}
} else {
if (!from || from.value != valuesFrom[idFrom]) {
shouldShowUp = false;
}
}
}
}
Expand Down

0 comments on commit b9d1b86

Please sign in to comment.