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
- Navigate to the desired Site, open the Site Menu (), and go to Content & Data → Forms.
- Click the Add button ().
- Click the Configuration button () for the new form.
- 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
- Add a form field that is compatible with the desired object field.
- Click the Advanced tab.
- Select the desired object field.
- In the Advanced tab, select the desired object field.
- Repeat the above process until all desired object fields are mapped to a form field.
- Map all desired object fields to the form fields.
- Design the form layout. See Forms documentation to learn more about this process.
- 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.
- Begin editing a content page or page template.
Display page templates do not support form fragments.
- (Optional) Design a layout using fragments.
- 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.
- Remove non-mandatory fields that you don’t want in the form.
- Drag and drop form fragments to reorganize them. By default, form elements are organized alphabetically.
- (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.
- 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.
- 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.