Textbox/Textarea elements
A TextboxFormElement
writes either an <input>
or a <textarea>
tag to the output.
Element and builder
The ViewElement
implementation is TextboxFormElement
, which also has a specialized version TextareaFormElement
.
Both of these elements can be configured via a TextboxViewElementBuilder
.
A builder can also be created by using the BootstrapViewElements.bootstrap.builders#textbox
factory methods.
Configurable attributes
A TextboxFormElement
can easily be customized through a variety of attributes.
Attribute | Description |
---|---|
type |
Specifies the |
placeholder |
Sets a placeholder that is rendered if no data is present. |
text |
The value that the element holds. |
maxLength |
The maximum amount of characters that can be entered in the field. |
disableLineBreaks |
Whether line breaks are allowed within the textbox or not. |
A TextAreaElement
is a specialized TextBoxFormElement
and contains some additional properties.
Setting | Description | Default value |
---|---|---|
rows |
The initial rows that should be available in the textarea |
3 |
autoSize |
Whether the textarea should grow and shrink with content that is added. |
true |
Type attribute
The type of a TextboxFormElement
influences the type of the html element that is rendered.
For example, instead of a text input element, a password input element could be rendered.
The default type for a TextboxFormElement
is TextboxFormElement.Type.TEXT
Following is a list of all available types:
-
TEXT
-
PASSWORD
-
DATETIME
-
DATETIME_LOCAL
-
DATE
-
MONTH
-
TIME
-
WEEK
-
NUMBER
-
EMAIL
-
URL
-
SEARCH
-
TEL
-
COLOR
Examples
Creating a textbox
import static com.foreach.across.modules.bootstrapui.ui.factories.BootstrapViewElements.bootstrap;
bootstrap.builders.textbox()
.build();
Multiline & Autosizing
Autosizing is provided by the Jack Moore Autosize library and is registered as an additional web resource via the BootstrapUiFormElementsWebResources
bundle.
Its functionality is executed based on the presence of a js-autosize
html class on the TextareaFormElement
that is rendered.
Unless explicitly set to false, autosizing will be active for the textarea element that is rendered.
bootstrap.builders.textbox()
.autoSize()
.multiLine( 3 )
.build();