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 [[Documentation/ModulesHowTo#CBImodels|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.
Creates a new section
An object describing an UCI section selected by the name. Use [[#A.3Asection.28.27.27sectionclass.27.27.2C....29|Map:section(NamedSection, name'', ''type'', ''title'', ''description)]] to instantiate.
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
Creates a new option
An object describing a group of UCI sections selected by their type. Use [[#A.3Asection.28.27.27sectionclass.27.27.2C....29|Map:section(TypedSection, type'', ''title'', ''description)]] to instantiate.
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 section names
Only select those sections where the option key'' == ''value
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.
Creates a new option optionclass: a class object of the section additional parameters passed to the constructor of the option class
An object describing an option in a section of a UCI File. Creates a standard text field in the formular. Use [[#A.3Aoption.28.27.27optionclass.27.27.2C....29|NamedSection:option(Value, option'', ''title'', ''description'')]] or [[#A.3Aoption.28.27.27optionclass.27.27.2C....29-1|TypedSection:option(Value, ''option'', ''title'', ''description)]] to instantiate.
The default value
The maximum length 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 size of the form field
Convert this text field into a combobox if possible and add a selection option.
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 an option in a section of a UCI File. Creates a list box in the formular. Use [[#A.3Aoption.28.27.27optionclass.27.27.2C....29|NamedSection:option(Value, option'', ''title'', ''description'')]] or [[#A.3Aoption.28.27.27optionclass.27.27.2C....29-1|TypedSection:option(Value, ''option'', ''title'', ''description)]] to instantiate.
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
selects the form widget to be used
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
An object describing an option with two possible values in a section of a UCI File. Creates a checkbox field in the formular. Use [[#A.3Aoption.28.27.27optionclass.27.27.2C....29|NamedSection:option(Value, option'', ''title'', ''description'')]] or [[#A.3Aoption.28.27.27optionclass.27.27.2C....29-1|TypedSection:option(Value, ''option'', ''title'', ''description)]] to instantiate.
The default value
the value that shoudl 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
The size of the form field
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 an option in a section of a UCI File. Creates several checkboxed as form fields. Use [[#A.3Aoption.28.27.27optionclass.27.27.2C....29|NamedSection:option(Value, option'', ''title'', ''description'')]] or [[#A.3Aoption.28.27.27optionclass.27.27.2C....29-1|TypedSection:option(Value, ''option'', ''title'', ''description)]] to instantiate.
The default value
The string which will be used to delimit the values
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
selects the form widget to be used
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 checkbox list
An object describing an option in a section of a UCI File. Creates a readonly field in the form. Use [[#A.3Aoption.28.27.27optionclass.27.27.2C....29|NamedSection:option(Value, option'', ''title'', ''description'')]] or [[#A.3Aoption.28.27.27optionclass.27.27.2C....29-1|TypedSection:option(Value, ''option'', ''title'', ''description)]] to instantiate.
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.
Similar to the MultiValue, but stores selected Values into a UCI list instead of a space-separated string.
A list of user-defined values.