Creating Forms Using Form Fragments

Use form fragments to create and manage forms on content pages or page templates. With form fragments, you can map fields to objects, organize layouts, and configure form settings. You can also handle object relationships, manage related data, and customize form elements to suit your site’s requirements.

Creating a Form

  1. Ensure a custom object is created before you start.

  2. Begin editing a content page or page template.

  3. (Optional) Design a layout using fragments. See Building Responsive Layouts with Fragments for more information.

  4. Add the Form Container fragment to the page and map it to an object.

    The container automatically generates a Submit button and fragments for all object fields. They appear in alphabetical order. Mandatory fields are marked accordingly.

    Add the form container and map it to an object.

    Liferay DXP 2024.Q3+/Portal 7.4 GA125+ In the pop-up, select the fields and related fields to display in the form. See Handling Object Relationships Within Form Container Fragments to learn more about managing related fields in form fragments.

  5. Remove non-mandatory fields that you don’t want in the form.

    Liferay DXP 2024.Q3+/Portal 7.4 GA125+ To manage available and related fields, select the Form Container fragment and click Manage Form Fields in the General tab on the right under Content Type.

    Use the Manage Form Fields button to manage available form fields and related fields.

  6. Drag and drop form fragments to reorganize them. By default, form elements are organized alphabetically.

  7. (Optional) Add basic fragments to the form container. You can use basic components (e.g., grids, separators, paragraphs, images) to provide structure and style to your form container.

    Add basic fragments to the form container and reorganize your page elements to create the desired structure.

  8. Configure the fragments. Form fragments include both standard and unique configuration options.

    Note

    Form fragment configuration options become available after mapping the fragment to an object field.

    Configure the form fragments.

  9. Beta Feature (Optional) If draft mode is enabled for the object, configure the Submitted Entry Status for the form’s submit button: Approved or Draft.

    Important

    When using form fragments to update entries in a display page, you cannot change an entry’s status from approved to draft.

    Configure the Submitted Entry Status for the form's submit button.

  10. Click Publish when finished.

Handling Object Relationships Within Form Container Fragments

Liferay DXP 2024.Q3+/Portal 7.4 GA125+

Manage relationships between objects and handle related data directly from Form Container fragments in content pages or display page templates.

To manage object relationships within form fragments,

  1. Create a content page or a display page template.

  2. Add a Form Container fragment to the page

  3. Once you select an object in a Form Container fragment, a window opens displaying available fields, including related fields, as selectable options. Select one or more fields and click Save to populate the form.

    In this example, the Employee Profile and Car objects have a one-to-many relationship, where each employee can be associated with multiple cars. When generating the form, you can select and combine fields from both objects to capture all the necessary information.

    Select fields to display in the form container fragment.

    Tip

    You can also create multi-step applications where users can navigate through different steps, such as entering employee details, assigning a car, and confirming the entries.

  4. After selecting the fields, manage them by clicking the Form Container fragment and using the Manage Form Fields button located in the General tab on the right under Content Type.

  5. Alternatively, select a text or picklist field and set the Source and Field options on the right to manage those fields manually.

    Manage text and picklist fields individually.

Capabilities

Product

Education

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy