backup MDL-24219 Fixed up dependencies JS for mforms
authorSam Hemelryk <sam@moodle.com>
Fri, 17 Sep 2010 03:30:15 +0000 (03:30 +0000)
committerSam Hemelryk <sam@moodle.com>
Fri, 17 Sep 2010 03:30:15 +0000 (03:30 +0000)
lib/form/form.js

index c1cb7a6..ad361a8 100644 (file)
@@ -223,7 +223,7 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
             _dependency_notchecked : function(elements, value) {
                 var lock = false;
                 elements.each(function(){
-                    if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
+                    if (this.getAttribute('type').toLowerCase()=='radio' && this.get('value') != value) {
                         return;
                     }
                     lock = lock || !Y.Node.getDOMNode(this).checked;
@@ -236,7 +236,7 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
             _dependency_checked : function(elements, value) {
                 var lock = false;
                 elements.each(function(){
-                    if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
+                    if (this.getAttribute('type').toLowerCase()=='radio' && this.get('value') != value) {
                         return;
                     }
                     lock = lock || Y.Node.getDOMNode(this).checked;
@@ -261,6 +261,8 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
                 elements.each(function(){
                     if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
                         return;
+                    } else if (this.getAttribute('type').toLowerCase() == 'checkbox' && !Y.Node.getDOMNode(this).checked) {
+                        return;
                     }
                     lock = lock || this.get('value') == value;
                 });
@@ -280,6 +282,8 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
                 elements.each(function(){
                     if (this.getAttribute('type').toLowerCase()=='radio' && !Y.Node.getDOMNode(this).checked) {
                         return;
+                    } else if (this.getAttribute('type').toLowerCase() == 'checkbox' && !Y.Node.getDOMNode(this).checked) {
+                        return;
                     }
                     lock = lock || this.get('value') != value;
                 });