OptionsFormElementBuilder
To quickly create a list of options, either as a select, list of checkboxes or list or radio buttons.
Element and builder
The OptionsFormElementBuilder
builds an AbstractNodeViewElement
.
A builder can be created using BootstrapUiBuilders.options()
factory methods.
This builder can be used to create a list of options.
The default implementation is a select
element which can be extended with a bootstrap-select
implementation.
OptionsFormElementBuilder attributes
Attribute | Description | Default |
---|---|---|
|
The type can be SELECT, RADIO or CHECKBOX |
SELECT by default |
|
Multiple options can be selected |
False by default |
|
Name of the element |
Not set by default |
|
Output radio elements |
Not set by default |
|
Output a select box |
Not set by default |
|
Output a checkbox |
Not set by default |
Examples
Creating an option list for a select field
Given the following builder configuration
BootstrapUiBuilders
.options()
.controlName( "demo" )
.add( BootstrapUiBuilders.option().label( "Orange" ).value( "orange" ) )
.add( BootstrapUiBuilders.option().label( "Apple" ).value( "apple" ) )
.build();
The following markup would be rendered:
<select name="demo" id="demo" class="form-control">
<option id="demo1" value="orange">Orange</option>
<option id="demo2" value="apple">Apple</option>
</select>