mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
form-javascript MDL-24024 Fixed bug with mforms JavaScript whereby dependencies on radio buttons were constantly returning true
This commit is contained in:
parent
c72b9900ed
commit
e2620b9d15
1 changed files with 17 additions and 5 deletions
|
@ -165,9 +165,9 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||||
hide = false;
|
hide = false;
|
||||||
checkfunction = '_dependency_'+condition;
|
checkfunction = '_dependency_'+condition;
|
||||||
if (Y.Lang.isFunction(this[checkfunction])) {
|
if (Y.Lang.isFunction(this[checkfunction])) {
|
||||||
result = this[checkfunction].apply(this, [this._depElements[dependon], value]);
|
result = this[checkfunction].apply(this, [this._depElements[dependon], value, e]);
|
||||||
} else {
|
} else {
|
||||||
result = this._dependency_default(this._depElements[dependon], value);
|
result = this._dependency_default(this._depElements[dependon], value, e);
|
||||||
}
|
}
|
||||||
lock = result.lock || false;
|
lock = result.lock || false;
|
||||||
hide = result.hide || false;
|
hide = result.hide || false;
|
||||||
|
@ -223,7 +223,10 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||||
_dependency_notchecked : function(elements, value) {
|
_dependency_notchecked : function(elements, value) {
|
||||||
var lock = false;
|
var lock = false;
|
||||||
elements.each(function(){
|
elements.each(function(){
|
||||||
lock = lock || !this.get('checked');
|
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lock = lock || !Y.Node.getDOMNode(this).checked;
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
lock : lock,
|
lock : lock,
|
||||||
|
@ -233,7 +236,10 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||||
_dependency_checked : function(elements, value) {
|
_dependency_checked : function(elements, value) {
|
||||||
var lock = false;
|
var lock = false;
|
||||||
elements.each(function(){
|
elements.each(function(){
|
||||||
lock = lock || this.get('checked');
|
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lock = lock || Y.Node.getDOMNode(this).checked;
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
lock : lock,
|
lock : lock,
|
||||||
|
@ -253,6 +259,9 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||||
_dependency_eq : function(elements, value) {
|
_dependency_eq : function(elements, value) {
|
||||||
var lock = false;
|
var lock = false;
|
||||||
elements.each(function(){
|
elements.each(function(){
|
||||||
|
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
lock = lock || this.get('value') == value;
|
lock = lock || this.get('value') == value;
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
@ -266,9 +275,12 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||||
hide : true
|
hide : true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_dependency_default : function(elements, value) {
|
_dependency_default : function(elements, value, ev) {
|
||||||
var lock = false;
|
var lock = false;
|
||||||
elements.each(function(){
|
elements.each(function(){
|
||||||
|
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
lock = lock || this.get('value') != value;
|
lock = lock || this.get('value') != value;
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue