Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jqhph committed Sep 14, 2021
1 parent b720864 commit 5608877
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Form/Field/CanCascadeFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ protected function getCascadeClass($value, string $operator)
'has' => '8',
];

return sprintf('cascade-%s-%s-%s', str_replace(' ', '-', $this->getElementClassString()), $value, $map[$operator]);
return str_replace(
'.',
'',
sprintf('cascade-%s-%s-%s', str_replace(' ', '-', $this->getElementClassString()), $value, $map[$operator])
);
}

protected function addCascadeScript()
Expand Down Expand Up @@ -152,26 +156,26 @@ protected function getCascadeScript()
if (! $.isArray(b)) {
return operator_table[o](a, b)
}
if (o === '!=') {
var result = true;
for (var i in b) {
if (! operator_table[o](a, b[i])) {
result = false;
break;
}
}
return result;
}
for (var i in b) {
if (operator_table[o](a, b[i])) {
return true;
}
}
};
var operator_table = {
'=': function(a, b) {
if ($.isArray(a) && $.isArray(b)) {
Expand All @@ -181,10 +185,10 @@ protected function getCascadeScript()
return String(a) === String(b);
},
'>': function(a, b) {
return a > b;
return a > b;
},
'<': function(a, b) {
return a < b;
return a < b;
},
'>=': function(a, b) { return a >= b; },
'<=': function(a, b) { return a <= b; },
Expand Down

0 comments on commit 5608877

Please sign in to comment.