luci-base: add 'create' boolean to MultiValue form widget
authorPaul Donald <newtwen+github@gmail.com>
Tue, 22 Oct 2024 23:01:50 +0000 (01:01 +0200)
committerPaul Donald <newtwen+github@gmail.com>
Tue, 22 Oct 2024 23:13:04 +0000 (01:13 +0200)
Enables creation of custom choices.

example usage:

o = s.taboption('thistab', form.MultiValue, 'myoption');
o.create = true;

Form element now presents additional ' -- custom -- ' entry.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
modules/luci-base/htdocs/luci-static/resources/form.js

index 624bc2c2f8a3f68d87dc01e0a0f8e0e141d71cc3..a228d3bf42c0579cf8ef381d157a213ef1b866b5 100644 (file)
@@ -4115,6 +4115,14 @@ var CBIMultiValue = CBIDynamicList.extend(/** @lends LuCI.form.MultiValue.protot
                this.placeholder = _('-- Please choose --');
        },
 
+       /**
+        * Allows custom value entry in addition to those already specified.
+        *
+        * @name LuCI.form.MultiValue.prototype#create
+        * @type boolean
+        * @default null
+        */
+
        /**
         * Allows to specify the [display_items]{@link LuCI.ui.Dropdown.InitOptions}
         * property of the underlying dropdown widget. If omitted, the value of
@@ -4146,6 +4154,7 @@ var CBIMultiValue = CBIDynamicList.extend(/** @lends LuCI.form.MultiValue.protot
                        multiple: true,
                        optional: this.optional || this.rmempty,
                        select_placeholder: this.placeholder,
+                       create: this.create,
                        display_items: this.display_size || this.size || 3,
                        dropdown_items: this.dropdown_size || this.size || -1,
                        validate: L.bind(this.validate, this, section_id),