IceG
January 27, 2022, 10:09am
1
Hi
Probably a silly question, but what control in LuCI JS allows the user to have multiple choices? I am trying to save the band selection in a user friendly way but I have no idea how this can be done "nicely" in LuCI JS.
Thanks for all the tips.
1 Like
jow
January 27, 2022, 11:14am
2
Best is to use a form.MultiValue
widget. In a rendered form it will look like this:
Backing code:
return null;
var subnetmask = firstsubnet.split('/')[1];
if (!isNaN(subnetmask))
subnetmask = network.prefixToMask(+subnetmask);
return subnetmask;
}
var cbiRichListValue = form.ListValue.extend({
renderWidget: function(section_id, option_index, cfgvalue) {
var choices = this.transformChoices();
var widget = new ui.Dropdown((cfgvalue != null) ? cfgvalue : this.default, choices, {
id: this.cbid(section_id),
sort: this.keylist,
optional: true,
select_placeholder: this.select_placeholder || this.placeholder,
custom_placeholder: this.custom_placeholder || this.placeholder,
validate: L.bind(this.validate, this, section_id),
disabled: (this.readonly != null) ? this.readonly : this.map.readonly
so = ss.taboption('ipv6-ra', cbiRichListValue, 'ra_flags', _('<abbr title="Router Advertisement">RA</abbr> Flags'),
_('Specifies the flags sent in <abbr title="Router Advertisement">RA</abbr> messages, for example to instruct clients to request further information via stateful DHCPv6.'));
so.value('managed-config', _('managed config (M)'),
_('The <em>Managed address configuration</em> (M) flag indicates that IPv6 addresses are available via DHCPv6.'));
so.value('other-config', _('other config (O)'),
_('The <em>Other configuration</em> (O) flag indicates that other information, such as DNS servers, is available via DHCPv6.'));
so.value('home-agent', _('mobile home agent (H)'),
_('The <em>Mobile IPv6 Home Agent</em> (H) flag indicates that the device is also acting as Mobile IPv6 home agent on this link.'));
so.multiple = true;
so.select_placeholder = _('none');
so.depends('ra', 'server');
so.depends({ ra: 'hybrid', master: '0' });
so.cfgvalue = function(section_id) {
var flags = L.toArray(uci.get('dhcp', section_id, 'ra_flags'));
return flags.length ? flags : [ 'other-config' ];
};
so.remove = function(section_id) {
uci.set('dhcp', section_id, 'ra_flags', [ 'none' ]);
};
1 Like
IceG
February 3, 2022, 7:14am
3
I have one more question.
Can I save the data selected in form.MultiValue using the handleSaveApply / handleSave buttons? I wanted to save some values and then execute a script that uses those data as arguments.
system
Closed
February 13, 2022, 7:14am
4
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.