LuCI. form

The LuCI form class provides high level abstractions for creating UCI- or JSON backed configurations forms.

To import the class in views, use 'require form', to import it in external JavaScript, use L.require("form").then(...).

A typical form is created by first constructing a LuCI.form.Map or LuCI.form.JSONMap instance using new and by subsequently adding sections and options to it. Finally render() is invoked on the instance to assemble the HTML markup and insert it into the DOM.

Example
'use strict';
'require form';

let m, s, o;

m = new form.Map('example', _('Example form'),
	_('This is an example form mapping the contents of /etc/config/example'));

s = m.section(form.NamedSection, 'first_section', 'example', _('The first section'),
	_('This sections maps "config example first_section" of /etc/config/example'));

o = s.option(form.Flag, 'some_bool', _('A checkbox option'));

o = s.option(form.ListValue, 'some_choice', _('A select element'));
o.value('choice1', _('The first choice'));
o.value('choice2', _('The second choice'));

m.render().then((node) => {
	document.body.appendChild(node);
});

Classes

AbstractElement
AbstractSection
AbstractValue
Button
DirectoryPicker
DummyValue
DynamicList
FileUpload
Flag
GridSection
HiddenValue
JSONMap
ListValue
Map
MultiValue
NamedSection
RangeSliderValue
RichListValue
SectionValue
TableSection
TextValue
TypedSection
Value