Package org.patternfly.component.form


package org.patternfly.component.form
Provides form components for building structured data entry interfaces.

This package contains the Form component and its sub-components for creating accessible, validated forms. Forms organize input controls into groups with labels, helper text, and validation feedback. The package includes text inputs, text areas, form selects, checkboxes, and radio buttons.

Components

Usage

A basic form with text inputs, checkboxes, and action buttons:

import static org.patternfly.component.button.Button.button;
import static org.patternfly.component.form.Checkbox.checkbox;
import static org.patternfly.component.form.Form.form;
import static org.patternfly.component.form.FormActionGroup.formActionGroup;
import static org.patternfly.component.form.FormGroup.formGroup;
import static org.patternfly.component.form.FormGroupControl.formGroupControl;
import static org.patternfly.component.form.FormGroupLabel.formGroupLabel;
import static org.patternfly.component.form.FormGroupRole.radiogroup;
import static org.patternfly.component.form.Radio.radio;
import static org.patternfly.component.form.TextInput.textInput;
import static org.patternfly.component.form.TextInputType.email;
import static org.patternfly.component.help.HelperText.helperText;

Form form = form()
        .addGroup(formGroup("name").required()
                .addLabel(formGroupLabel("Full name"))
                .addControl(formGroupControl()
                        .addControl(textInput("name"))
                        .addHelperText(helperText("Include your middle name if you have one."))))
        .addGroup(formGroup("email").required()
                .addLabel(formGroupLabel("Email"))
                .addControl(formGroupControl()
                        .addControl(textInput(email, "email"))))
        .addGroup(formGroup("timezone").role(radiogroup)
                .addLabel(formGroupLabel("Timezone"))
                .addControl(formGroupControl().inline()
                        .addRadio(radio("tz-0", "timezone", "Eastern"))
                        .addRadio(radio("tz-1", "timezone", "Central"))
                        .addRadio(radio("tz-2", "timezone", "Pacific"))))
        .addActionGroup(formActionGroup()
                .addButton(button("Submit").primary())
                .addButton(button("Cancel").link()));
See Also: