diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-07-09 14:07:09 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-09 14:09:22 +0200 |
commit | ce04d7f0407c443e337f2a84c65be876f61dccac (patch) | |
tree | 9a043832c888b4339671d350d24a38c334201a1b /modules/luci-base/htdocs/luci-static | |
parent | 9f1757a8af90369ab3d1ec4a6d7f08d0c0ae4ec5 (diff) |
luci-base: fix label-to-input association in js cbi maps
Fixes: #2845
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/form.js | 2 | ||||
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/ui.js | 20 |
2 files changed, 11 insertions, 11 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 853b01ee3d..508e2c4857 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -1361,7 +1361,7 @@ var CBIValue = CBIAbstractValue.extend({ if (typeof(this.title) === 'string' && this.title !== '') { optionEl.appendChild(E('label', { 'class': 'cbi-value-title', - 'for': 'cbid.%s.%s.%s'.format(config_name, section_id, this.option) + 'for': 'widget.cbid.%s.%s.%s'.format(config_name, section_id, this.option) }, this.titleref ? E('a', { 'class': 'cbi-title-ref', diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js index 28d1fa90ae..69698de308 100644 --- a/modules/luci-base/htdocs/luci-static/resources/ui.js +++ b/modules/luci-base/htdocs/luci-static/resources/ui.js @@ -97,6 +97,7 @@ var UITextfield = UIElement.extend({ } frameEl.appendChild(E('input', { + 'id': this.options.id ? 'widget.' + this.options.id : null, 'name': this.options.name, 'type': this.options.password ? 'password' : 'text', 'class': this.options.password ? 'cbi-input-password' : 'cbi-input-text', @@ -168,6 +169,7 @@ var UICheckbox = UIElement.extend({ })); frameEl.appendChild(E('input', { + 'id': this.options.id ? 'widget.' + this.options.id : null, 'name': this.options.name, 'type': 'checkbox', 'value': this.options.value_enabled, @@ -224,7 +226,7 @@ var UISelect = UIElement.extend({ }, render: function() { - var frameEl, + var frameEl = E('div', { 'id': this.options.id }), keys = Object.keys(this.choices); if (this.options.sort === true) @@ -233,16 +235,16 @@ var UISelect = UIElement.extend({ keys = this.options.sort; if (this.options.widget == 'select') { - frameEl = E('select', { - 'id': this.options.id, + frameEl.appendChild(E('select', { + 'id': this.options.id ? 'widget.' + this.options.id : null, 'name': this.options.name, 'size': this.options.size, 'class': 'cbi-input-select', 'multiple': this.options.multi ? '' : null - }); + })); if (this.options.optional) - frameEl.appendChild(E('option', { + frameEl.lastChild.appendChild(E('option', { 'value': '', 'selected': (this.values.length == 0 || this.values[0] == '') ? '' : null }, this.choices[''] || this.options.placeholder || _('-- Please choose --'))); @@ -251,22 +253,19 @@ var UISelect = UIElement.extend({ if (keys[i] == null || keys[i] == '') continue; - frameEl.appendChild(E('option', { + frameEl.lastChild.appendChild(E('option', { 'value': keys[i], 'selected': (this.values.indexOf(keys[i]) > -1) ? '' : null }, this.choices[keys[i]] || keys[i])); } } else { - frameEl = E('div', { - 'id': this.options.id - }); - var brEl = (this.options.orientation === 'horizontal') ? document.createTextNode(' ') : E('br'); for (var i = 0; i < keys.length; i++) { frameEl.appendChild(E('label', {}, [ E('input', { + 'id': this.options.id ? 'widget.' + this.options.id : null, 'name': this.options.id || this.options.name, 'type': this.options.multi ? 'checkbox' : 'radio', 'class': this.options.multi ? 'cbi-input-checkbox' : 'cbi-input-radio', @@ -1152,6 +1151,7 @@ var UIDynamicList = UIElement.extend({ } else { var inputEl = E('input', { + 'id': this.options.id ? 'widget.' + this.options.id : null, 'type': 'text', 'class': 'cbi-input-text', 'placeholder': this.options.placeholder |