const CBIDynamicList = CBIValue.extend(/** @lends LuCI.form.DynamicList.prototype */ {
__name__: 'CBI.DynamicList',
+ /**
+ * Allows the underlying form controls to have multiple identical values.
+ *
+ * Default is `null`. If `true`, the underlying form value will
+ * not be checked for duplication.
+ *
+ * @name LuCI.form.DynamicList.prototype#allowduplicates
+ * @type boolean
+ * @default null
+ */
+
/** @private */
renderWidget(section_id, option_index, cfgvalue) {
const value = (cfgvalue != null) ? cfgvalue : this.default;
const widget = new ui.DynamicList(items, choices, {
id: this.cbid(section_id),
sort: this.keylist,
+ allowduplicates: this.allowduplicates,
optional: this.optional || this.rmempty,
datatype: this.datatype,
placeholder: this.placeholder,
exists = true;
});
- if (!exists) {
+ if (this.options.allowduplicates || !exists) {
const ai = dl.querySelector('.add-item');
ai.parentNode.insertBefore(new_item, ai);
}
return;
sbIn.setValues(sbEl, null);
- sbVal.element.setAttribute('unselectable', '');
+ if (!this.options.allowduplicates)
+ sbVal.element.setAttribute('unselectable', '');
if (sbVal.element.hasAttribute('created')) {
sbVal.element.removeAttribute('created');