-
Notifications
You must be signed in to change notification settings - Fork 2.5k
CBI models are Lua files describing the structure of an UCI config file and the resulting HTML form to be evaluated by the CBI parser.
All CBI model files must return an object of type luci.cbi.Map
.
For a commented example of a CBI model, see the Writing Modules tutorial.
The scope of a CBI model file is automatically extended by the contents of the module luci.cbi
and the translate
function from luci.i18n
.
This Reference covers the basics of the CBI system.
This is the root object of the model.
-
config:
configuration filename to be mapped, see UCI documentation and the files in/etc/config
-
title:
title shown in the UI -
description:
description shown in the UI
Creates a new section
-
sectionclass
: a class object of the section - additional parameters passed to the constructor of the section class
An object describing an UCI section selected by the name.
To instantiate use: Map:section(NamedSection, "name", "type", "title", "description")
-
name:
UCI section name -
type:
UCI section type -
title:
The title shown in the UI -
description:
description shown in the UI
Creates a new option
-
optionclass:
a class object of the section - additional parameters passed to the constructor of the option class
Allows the user to remove and recreate the configuration section.
Marks this section as dynamic. Dynamic sections can contain an undefinded number of completely userdefined options.
Parse optional options
An object describing a group of UCI sections selected by their type.
To instantiate use: Map:section(TypedSection, "type", "title", "description")
-
type:
UCI section type -
title:
The title shown in the UI -
description:
description shown in the UI
Creates a new option
-
optionclass:
a class object of the section - additional parameters passed to the constructor of the option class
Only show this option field if another option key
is set to value
in the same section.
If you call this function several times the dependencies will be linked with "or"
You can override this function to filter certain sections that will not be parsed.
The filter function will be called for every section that should be parsed and returns nil
for sections that should be filtered.
For all other sections it should return the section name as given in the second parameter.
Allows the user to remove and recreate the configuration section
Marks this section as dynamic. Dynamic sections can contain an undefinded number of completely userdefined options.
Parse optional options
Do not show UCI section names
An object describing an option in a section of a UCI File. Creates a standard text field in the formular.
To instantiate use: NamedSection:option(Value, "option", "title", "description")
or TypedSection:option(Value, "option", "title", "description")
-
option:
UCI option name -
title:
The title shown in the UI -
description:
description shown in the UI
Only show this option field if another option key
is set to value
in the same section.
If you call this function several times the dependencies will be linked with "or"
Convert this text field into a combobox if possible and add a selection option.
The default value
The maximum input length (of chars) of the value
Marks this option as optional, implies .rmempty = true
Removes this option from the configuration file when the user enters an empty value
The maximum number of chars displayed by form field
An object describing an option in a section of a UCI File.
Creates a list box or list of radio (for selecting one of many choices) in the formular.
To instantiate use: NamedSection:option(ListValue, "option", "title", "description")
or TypedSection:option(ListValue, "option", "title", "description")
-
option:
UCI option name -
title:
The title shown in the UI -
description:
description shown in the UI
Only show this option field if another option key
is set to value
in the same section.
If you call this function several times the dependencies will be linked with "or"
Adds an entry to the selection list
select
shows a selection list, radio
shows a list of radio buttons inside form
The default value
Marks this option as optional, implies .rmempty = true
Removes this option from the configuration file when the user enters an empty value
The size of the form field
An object describing an option with two possible values in a section of a UCI File.
Creates a checkbox field in the formular.
To instantiate use: NamedSection:option(Flag, "option", "title", "description")
or TypedSection:option(Flag, "option", "title", "description")
-
option:
UCI option name -
title:
The title shown in the UI -
description:
description shown in the UI
Only show this option field if another option key
is set to value
in the same section.
If you call this function several times the dependencies will be linked with "or"
The default value
the value that should be set if the checkbox is unchecked
the value that should be set if the checkbox is checked
Marks this option as optional, implies .rmempty = true
Removes this option from the configuration file when the user enters an empty value
An object describing an option in a section of a UCI File.
Creates a list of checkboxed or a multiselectable list as form fields.
To instantiate use: NamedSection:option(MultiValue, "option", "title", "description")
or TypedSection:option(MultiValue, "option", "title", "description")
-
option:
UCI option name -
title:
The title shown in the UI -
description:
description shown in the UI
Only show this option field if another option key
is set to value
in the same section.
If you call this function several times the dependencies will be linked with "or"
Adds an entry to the list
select
shows a selection list, checkbox
shows a list of checkboxes inside form
The string which will be used to delimit the values inside stored option
The default value
Marks this option as optional, implies .rmempty = true
Removes this option from the configuration file when the user enters an empty value
The size of the form field (only used if property .widget = "select"
)
Similar to the MultiValue
, but stores selected Values into a UCI list instead of a character-separated option.
A extensible list of user-defined values. Stores Values into a UCI list
Creates a readonly text in the form. !It writes no data to UCI!
To instantiate use: NamedSection:option(DummyValue, "option", "title", "description")
or TypedSection:option(DummyValue, "option", "title", "description")
-
option:
UCI option name -
title:
The title shown in the UI -
description:
description shown in the UI
Only show this option field if another option key
is set to value
in the same section.
If you call this function several times the dependencies will be linked with "or"
An object describing a multi-line textbox in a section in a non-UCI form.
An object describing a Button in a section in a non-UCI form.