Skip to content

FormField

The building block for user input. A FormField defines a single typed input inside a FormLayout.

FormField.builder()
.id("name")
.label("Name")
.dataType(FieldDataType.string)
.required(true)
.initialValue("Mateu")
.build()
PropertyTypeDefaultDescription
idStringField identifier — used to read/write the value in state
labelStringHuman-readable label
dataTypeFieldDataTypeThe type of data this field holds
stereotypeFieldStereotyperegularRendering hint (password, email, textarea, …)
readOnlybooleanfalseDisables editing
requiredbooleanfalseMarks the field as mandatory
autofocusbooleanfalseGives the field focus on load
placeholderStringPlaceholder text
descriptionStringHelper text shown below the field
optionsList<Option>[]Fixed choices for select / radio / checkbox fields
remoteCoordinatesRemoteCoordinatesEndpoint for dynamic option loading
initialValueObjectValue pre-filled when the form loads
colspanint1Number of FormLayout columns this field spans
sliderMinint0Minimum value for slider stereotype
sliderMaxint100Maximum value for slider stereotype
stepButtonsVisiblebooleanfalseShows +/- buttons on numeric fields
stepdouble1Increment step for numeric fields
styleStringInline CSS for the field
cssClassesStringCSS class names
ValueRendered as
stringText field
integerInteger number field
numberDecimal number field
moneyCurrency amount field
booleanCheckbox
dateDate picker
timeTime picker
dateTimeDate-time picker

Stereotypes refine how a field is rendered without changing its data type.

ValueDescription
regularDefault input (text field, number field, etc.)
passwordMasked text input
emailEmail input
textareaMulti-line text area
richTextRich text / WYSIWYG editor
markdownMarkdown editor
htmlRaw HTML display
linkHyperlink display
imageImage upload / display
colorColour picker
iconIcon selector
sliderSlider (range input)
starsStar rating input
selectDropdown select
comboBoxSearchable combo box
radioButtonsRadio button group
checkboxesCheckbox group
listBoxList box (multi-select)
multiSelectComboBoxMulti-select combo box
fileFile upload
editableGridInline editable grid
gridRead-only embedded grid
// Plain text
FormField.builder().id("name").label("Name").dataType(FieldDataType.string).build()
// Password
FormField.builder().id("pwd").label("Password")
.dataType(FieldDataType.string).stereotype(FieldStereotype.password).build()
// Textarea
FormField.builder().id("bio").label("Bio")
.dataType(FieldDataType.string).stereotype(FieldStereotype.textarea).build()
// Email
FormField.builder().id("email").label("Email")
.dataType(FieldDataType.string).stereotype(FieldStereotype.email).build()
// Integer with step buttons
FormField.builder().id("qty").label("Quantity")
.dataType(FieldDataType.integer).stepButtonsVisible(true).step(1).build()
// Decimal
FormField.builder().id("price").label("Price")
.dataType(FieldDataType.number).build()
// Currency
FormField.builder().id("amount").label("Amount")
.dataType(FieldDataType.money).build()
// Slider
FormField.builder().id("rating").label("Rating")
.dataType(FieldDataType.integer).stereotype(FieldStereotype.slider)
.sliderMin(1).sliderMax(10).build()
FormField.builder().id("active").label("Active")
.dataType(FieldDataType.boolean_).build()
FormField.builder().id("dob").label("Date of birth").dataType(FieldDataType.date).build()
FormField.builder().id("start").label("Start time").dataType(FieldDataType.time).build()
FormField.builder().id("created").label("Created at").dataType(FieldDataType.dateTime).build()
FormField.builder()
.id("status")
.label("Status")
.dataType(FieldDataType.string)
.stereotype(FieldStereotype.select)
.options(List.of(
new Option("active", "Active"),
new Option("inactive", "Inactive")
))
.build()
FormField.builder()
.id("code")
.label("Code")
.dataType(FieldDataType.string)
.readOnly(true)
.initialValue("AUTO-001")
.build()
FormField.builder()
.id("notes")
.label("Notes")
.dataType(FieldDataType.string)
.stereotype(FieldStereotype.textarea)
.colspan(2)
.build()