mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
MDL-27045 formslib: fix disabledif for advcheckbox
This is based on earlier work by Henning Bostelmann and Tom Potts.
This commit is contained in:
parent
f71e41691a
commit
8f6384a9ec
@ -237,6 +237,10 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||
_dependency_notchecked : function(elements, value) {
|
||||
var lock = false;
|
||||
elements.each(function(){
|
||||
if (this.getAttribute('type').toLowerCase()=='hidden' && !this.siblings('input[type=checkbox][name="' + this.get('name') + '"]').isEmpty()) {
|
||||
// This is the hidden input that is part of an advcheckbox.
|
||||
return;
|
||||
}
|
||||
if (this.getAttribute('type').toLowerCase()=='radio' && this.get('value') != value) {
|
||||
return;
|
||||
}
|
||||
@ -250,6 +254,10 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||
_dependency_checked : function(elements, value) {
|
||||
var lock = false;
|
||||
elements.each(function(){
|
||||
if (this.getAttribute('type').toLowerCase()=='hidden' && !this.siblings('input[type=checkbox][name="' + this.get('name') + '"]').isEmpty()) {
|
||||
// This is the hidden input that is part of an advcheckbox.
|
||||
return;
|
||||
}
|
||||
if (this.getAttribute('type').toLowerCase()=='radio' && this.get('value') != value) {
|
||||
return;
|
||||
}
|
||||
@ -272,10 +280,16 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||
},
|
||||
_dependency_eq : function(elements, value) {
|
||||
var lock = false;
|
||||
var hidden_val = false;
|
||||
elements.each(function(){
|
||||
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
|
||||
return;
|
||||
} else if (this.getAttribute('type').toLowerCase() == 'hidden' && !this.siblings('input[type=checkbox][name="' + this.get('name') + '"]').isEmpty()) {
|
||||
// This is the hidden input that is part of an advcheckbox.
|
||||
hidden_val = (this.get('value') == value);
|
||||
return;
|
||||
} else if (this.getAttribute('type').toLowerCase() == 'checkbox' && !Y.Node.getDOMNode(this).checked) {
|
||||
lock = lock || hidden_val;
|
||||
return;
|
||||
}
|
||||
//check for filepicker status
|
||||
@ -303,10 +317,16 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
|
||||
},
|
||||
_dependency_default : function(elements, value, ev) {
|
||||
var lock = false;
|
||||
var hidden_val = false;
|
||||
elements.each(function(){
|
||||
if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
|
||||
return;
|
||||
} else if (this.getAttribute('type').toLowerCase() == 'hidden' && !this.siblings('input[type=checkbox][name="' + this.get('name') + '"]').isEmpty()) {
|
||||
// This is the hidden input that is part of an advcheckbox.
|
||||
hidden_val = (this.get('value') != value);
|
||||
return;
|
||||
} else if (this.getAttribute('type').toLowerCase() == 'checkbox' && !Y.Node.getDOMNode(this).checked) {
|
||||
lock = lock || hidden_val;
|
||||
return;
|
||||
}
|
||||
//check for filepicker status
|
||||
|
@ -1970,7 +1970,11 @@ function validate_' . $this->_formName . '(frm) {
|
||||
} else if (is_a($element, 'HTML_QuickForm_hidden')) {
|
||||
return array();
|
||||
|
||||
} else if (method_exists($element, 'getPrivateName')) {
|
||||
} else if (method_exists($element, 'getPrivateName') &&
|
||||
!($element instanceof HTML_QuickForm_advcheckbox)) {
|
||||
// The advcheckbox element implements a method called getPrivateName,
|
||||
// but in a way that is not compatible with the generic API, so we
|
||||
// have to explicitly exclude it.
|
||||
return array($element->getPrivateName());
|
||||
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user