summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/form.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js
index 32d803d6a..568a4abb6 100644
--- a/modules/luci-base/htdocs/luci-static/resources/form.js
+++ b/modules/luci-base/htdocs/luci-static/resources/form.js
@@ -1156,6 +1156,36 @@ var CBIAbstractSection = CBIAbstractElement.extend(/** @lends LuCI.form.Abstract
return rv;
},
+ /**
+ * Obtain underlying option objects.
+ *
+ * This function is sensitive to the amount of arguments passed to it;
+ * if no option name is specified, all options within this section are
+ * returned as dictionary.
+ *
+ * If an option name is supplied, this function returns the matching
+ * LuCI.form.AbstractValue instance only.
+ *
+ * @param {string} [option]
+ * The name of the option object to obtain
+ *
+ * @returns {null|LuCI.form.AbstractValue|Object<string, LuCI.form.AbstractValue>}
+ * Returns either a dictionary of option names and their corresponding
+ * option instance objects or just a single object instance value,
+ * depending on the amount of passed arguments.
+ */
+ getOption: function(option) {
+ var rv = (arguments.length == 0) ? {} : null;
+
+ for (var i = 0, o; (o = this.children[i]) != null; i++)
+ if (rv)
+ rv[o.option] = o;
+ else if (o.option == option)
+ return o;
+
+ return rv;
+ },
+
/** @private */
renderUCISection: function(section_id) {
var renderTasks = [];