logo

Get in touch

Awesome Image Awesome Image

Liferay February 23, 2023

Integrating Object in Liferay Form

Written by Mahipalsinh Rana

1.5K

Liferay objects are integrated with the Forms application, so you can design forms for receiving user input and creating object entries. To do this, first add a new form and configure it to use the object’s storage type. Then select the desired object, design your form, and map its fields to the selected object’s fields.

Adding a form for creating object entries 

  1. Navigate to the desired Site, open the Site Menu (), and go to Content & DataForms.
  2. Click the Add button ().
  3. Click the Configuration button () for the new form.
  4. Select the Object storage type and the object you want to use with the form.
    This configures the form to store data for the selected object. 

Mapping Form Fields to Object Fields

  1. Add a form field that is compatible with the desired object field.
  2. Click the Advanced tab.
  3. Select the desired object field.
  4. In the Advanced tab, select the desired object field.
  5. Repeat the above process until all desired object fields are mapped to a form field.
  6. Map all desired object fields to the form fields.
  7. Design the form layout. See Forms documentation to learn more about this process.
  8. Once you’ve finished designing the form, click Publish to finish form creation. 

After publishing, the form can be used to create object entries for the selected object.

Important Note: 

Mapping requirements:

  • All form fields must map to an object field to prevent data loss.
  • All required object fields must be mapped to a form field.
  • Attachment and relationship aren’t compatible with form fields 

Using fragment to build forms 

Note: (Available Liferay 7.4 U45+/GA45+)

Liferay includes form fragments for building object 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. 

  1. Begin editing a content page or page template.
    Display page templates do not support form fragments.
  2. (Optional) Design a layout using fragments.
  3. 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 field are marked accordingly.
     unnamed (27)
  4. Remove non-mandatory fields that you don’t want in the form.
  5. Drag and drop form fragments to reorganize them. By default, form elements are organized alphabetically.
  6. (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.

    unnamed (28)

  7. 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.
    unnamed (29) 
  8. Click Publish when finished. 

Conclusion

Liferay provides a user-friendly way to integrate objects with the Forms application. By following the steps outlined in this article, users can easily add a new form, configure it to use the objects storage type, select the desired object, design their form, and map its fields to the selected object’s fields. The use of form fragments also allows for efficient and customizable form creation in content pages. It is important to note that all form fields must map to an object field to prevent data loss and all required object fields must be mapped to a form field. Additionally, attachments and relationships are not compatible with form fields. Overall, this feature in Liferay allows for streamlined and organized data collection and storage.

Bringing Software Development Expertise to Every
Corner of the World

United States

India

Germany

United Kingdom

Canada

Singapore

Australia

New Zealand

Dubai

Qatar

Kuwait

Finland

Brazil

Netherlands

Ireland

Japan

Kenya

South Africa