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

Type

The type can be SELECT, RADIO or CHECKBOX

SELECT by default

multiple

Multiple options can be selected

False by default

controlName

Name of the element

Not set by default

radio

Output radio elements

Not set by default

select

Output a select box

Not set by default

checkbox

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>