FormViewElement
A FormViewElement
writes a <form>
element to the output.
Element and builder
The FormViewElement
has an equivalent FormViewElementBuilder
.
A builder can be created using BootstrapViewElements.bootstrap.builders.form()
factory methods.
FormViewElement attributes
Attribute | Description | Default |
---|---|---|
|
Set the command object that should be bound to this form. |
Not set by default |
|
Set the |
Not set by default |
|
Url to use for the action attribute |
Not set by default |
|
Create a multipart form by setting the correct encType. The |
Not set by default |
|
Set the formLayout to be used: |
By default uses the |
|
Add a |
Not set by default |
|
Provide a |
Not set by default |
Examples
Simple form with no elements
import static com.foreach.across.modules.bootstrapui.ui.factories.BootstrapViewElements.bootstrap;
bootstrap.builders
.form()
.formName( "contact" )
.noValidate()
.htmlId( "contact" )
.build();
Full form example
import static com.foreach.across.modules.bootstrapui.styles.BootstrapStyles.css;
import static com.foreach.across.modules.bootstrapui.ui.factories.BootstrapViewElements.bootstrap;
bootstrap.builders.form()
.commandObject( data )
.add(
bootstrap.builders
.formGroup()
.label( "My number" )
.tooltip( bootstrap.builders.tooltip().text( "another tooltip" ) )
.required()
.detectFieldErrors( true )
.control(
bootstrap.builders.textbox()
.controlName( "number" )
.text( "" + data.getNumber() )
)
)
.add(
bootstrap.builders
.formGroup()
.tooltip( bootstrap.builders
.tooltip()
.text( "hello" ) )
.control( bootstrap.builders
.checkbox()
.controlName( "checkme" )
.label( "Check me out" )
)
)
.add(
bootstrap.builders.formGroup()
.label( "My text" )
.descriptionBlock( "My text is a very important field containing... your text!" )
.helpBlock( "Please fill in all the data" )
.control( bootstrap.builders.textbox().controlName( "mytext" ) )
)
.add(
bootstrap.builders.formGroup()
.control( bootstrap.builders.checkbox().controlName( "checkmetoo" ).label( "Try me babe" ) )
.helpBlock( "Try clicking *on* the checkbox in front of you." )
)
.add( bootstrap.builders.row().add( bootstrap.builders.column( Grid.Device.MD.width( 12 ) )
.add( bootstrap.builders.button( css.button.primary ).submit()
.text( "Update" ) ) ) );