Permalink
Browse files

Merge branch 'MDL-34728_23' of git://github.com/timhunt/moodle into M…

…OODLE_23_STABLE
  • Loading branch information...
2 parents 9a77ed0 + 3350475 commit b92d962c3f46dc5ddfbe671b947c8faf4e6d7e37 @danpoltawski danpoltawski committed Aug 14, 2012
Showing with 20 additions and 3 deletions.
  1. +20 −3 lib/form/form.js
View
@@ -59,6 +59,11 @@ M.form.initShowAdvanced = function(Y, config) {
};
/**
+ * Stores a list of the dependencyManager for each form on the page.
+ */
+M.form.dependencyManagers = {};
+
+/**
* Initialises a manager for a forms dependencies.
* This should happen once per form.
*/
@@ -128,7 +133,7 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
return this.checkDependencies(null);
},
/**
- * Gets all elements in the form by thier name and returns
+ * Gets all elements in the form by their name and returns
* a YUI NodeList
* @return Y.NodeList
*/
@@ -352,5 +357,17 @@ M.form.initFormDependencies = function(Y, formid, dependencies) {
return dependencyManager;
})();
- return new M.form.dependencyManager();
-};
+ M.form.dependencyManagers[formid] = new M.form.dependencyManager();
+ return M.form.dependencyManagers[formid];
+};
+
+/**
+ * Update the state of a form. You need to call this after, for example, changing
+ * the state of some of the form input elements in your own code, in order that
+ * things like the disableIf state of elements can be updated.
+ */
+M.form.updateFormState = function(formid) {
+ if (formid in M.form.dependencyManagers) {
+ M.form.dependencyManagers[formid].checkDependencies(null);
+ }
+};

0 comments on commit b92d962

Please sign in to comment.