Using Form Fragments

Liferay DXP 2023.Q3+/Portal GA92+

Liferay includes form fragments for building forms in content pages. To build a form, add a form container to a content page or page template and map it to a published object. The container automatically populates fragments mapped to each object field. You can organize, remove, or add fragments manually. Once published, end users can create object entries using the form.

You can also create forms with multiple steps by adding form fragments to different sections and using navigation buttons to guide users through each step. See Using Fragments to Build Multi-Step Forms.

To build forms in content pages,

  • Create a custom object.
  • Add a Form Container fragment to a content page.
  • Map the Form Container fragment to the custom object.
  • Place form fragments only in a mapped form container.
  • Map every form fragment in the form to an object field to prevent data loss.
  • Include fragments in the form container for all mandatory object fields.
  • Make mandatory form fragments visible.
  • Include a visible submit button in the form container.
Note

When mapping an object to a Form Container fragment, a Submit button is generated. You can map its text using mapping settings.

To create a button with link settings for redirection, add type="button" to the button fragment.

By default, Liferay includes the Form Components fragment set, but you can create your own. See Creating Form Fragments for more information.

In addition, form fragments can only be used with custom objects. Therefore, Liferay hides the Form Components fragment set until you have at least one published object. Once published, users with access to the object can view and use the Form Components fragments.

Default Form Fragments

Liferay provides the following form fragments in the Form Components set. Each fragment corresponds to an object field type or provides additional functionality for building forms.

Form FragmentDescription
CAPTCHAAdds a CAPTCHA challenge to prevent automated submissions.
CategoriesUI to categorize the entry using available vocabularies.
CheckboxDisplays a single checkbox for boolean values.
DateProvides a date picker field.
Date and TimeProvides a combined date and time picker field.
Liferay DXP 2025.Q4 Drag and Drop UploadUI to upload files through drag and drop.
File UploadUI to upload a local file.
Form ButtonAdds a custom button element to the form.
Form ContainerRequired container for all form fragments. Must be mapped to an object.
Form RelationshipMaps the form field to a related content type and creates relationships between entries.
Liferay DXP 2025.Q4 Inline TextAdds editable text directly within the form layout.
Localization SelectUI to select a language for localized fields.
MultiselectDisplays a list of options with multiple selection enabled.
NumericProvides a numeric input for integer or decimal values.
Rich TextDisplays a rich text editor field.
SelectDisplays a drop-down list with single selection.
StepperDisplays navigation steps for multi-step forms.
TagsUI to add tags to the object entry.
TextProvides a single-line text input.
TextareaProvides a multi-line text input.
Liferay DXP 2025.Q4 URL Video PreviewerDisplays a preview of a video from a provided URL.

Supported Field Types for Form Components

Each form fragment can support one or more object field types. The default form components support these fields.

Form FragmentObject Field Types
CAPTCHAN/A
CheckboxBoolean
DateDate
File UploadAttachment
Multi-select ListMultiple Picklist
Numeric InputInteger, Long Integer, Decimal, Precision Decimal
Rich TextRich Text
Select from ListRelationship, Picklist
Submit ButtonN/A
Text InputText, Long Text
Text AreaText, Long Text
Tip

If categorization is enabled for the object, you can use the Tags and Categories form fragments to add metadata to object entries.