From 2d3470b700237f1c71138c085a4f73c7a809d1a0 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 27 Jul 2019 22:17:33 +0200 Subject: [PATCH] luci-base: don't treat .rmempty flag as optional for ListValue widgets Restore the old CBI behaviour of not automatically rendering empty selection choices in ListValue select dropdowns when .rmempty is specified. Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/form.js | 2 +- modules/luci-base/htdocs/luci-static/resources/ui.js | 2 +- modules/luci-base/luasrc/view/cbi/lvalue.htm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 58d8f7100c..ef2f18e35a 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -1460,7 +1460,7 @@ var CBIListValue = CBIValue.extend({ id: this.cbid(section_id), size: this.size, sort: this.keylist, - optional: this.rmempty || this.optional, + optional: this.optional, placeholder: this.placeholder, validate: L.bind(this.validate, this, section_id) }); diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 43afc698f6..2ba0b0d1e8 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -243,7 +243,7 @@ var UISelect = UIElement.extend({ 'multiple': this.options.multiple ? '' : null })); - if (this.options.optional) + if (this.options.optional || this.choices.hasOwnProperty('')) frameEl.lastChild.appendChild(E('option', { 'value': '', 'selected': (this.values.length == 0 || this.values[0] == '') ? '' : null diff --git a/modules/luci-base/luasrc/view/cbi/lvalue.htm b/modules/luci-base/luasrc/view/cbi/lvalue.htm index 920b5e9f92..28141472f4 100644 --- a/modules/luci-base/luasrc/view/cbi/lvalue.htm +++ b/modules/luci-base/luasrc/view/cbi/lvalue.htm @@ -7,7 +7,7 @@ sort = self.keylist, widget = self.widget, datatype = self.datatype, - optional = self.optional or self.rmempty, + optional = self.optional, placeholder = self.placeholder } }))%>> -- 2.30.2