Using Forms with Objects
Liferay 7.4+
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 objects storage type. Then select the desired object, design your form, and map its fields to the selected object’s fields.
- You can use the Forms application’s rules and validations with objects.
- You cannot use the Forms application’s data providers with objects.
- You cannot map object relationships to form fields. See Designing Object Layouts for how to create custom layouts that include object relationships.
Adding a Form for an Object
Follow these steps to add 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.
noteOnly published, active objects appear. You can only connect a form to one object at a time, though you can connect objects to multiple forms.
-
Click Done.
Once linked to the desired object, you can add field elements to the form and map them to the object’s fields.
Mapping Form Fields to Object Fields
Follow these steps to map a form field to an object field.
-
Add a form field that is compatible with the desired object field.
See Field Compatibility Reference for a list of which form fields are compatible with each type of object field.
-
Click the Advanced tab.
-
Select the desired object field.
warningWhen mapped to a required object field, the form field is marked required automatically. If you’re using a form rule to hide a required field conditionally, you must ensure it contains appropriate data or form submission fails. Using a predefined value with an autofill rule can help ensure that a required hidden field is populated properly.
-
Repeat the above process until all desired object fields are mapped to a form field.
noteAn object field can only be mapped to one form field.
-
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.
importantBefore you can publish an object form, it must fulfill all mapping requirements.
After publishing, the form can be used to create object entries for the selected object.
Mapping Requirements
All forms with the Objects storage type have the following 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.
Attempting to publish a form with invalid mappings displays an error message that identifies what’s wrong.
Field Compatibility Reference
Object Field Types | Compatible Form Fields |
---|---|
Attachment | ❌ |
Boolean | Boolean (checkbox) |
Date | Date |
Decimal (previously Double) | Numeric → Decimal |
Integer | Numeric → Integer |
Long Integer (previously Long) | Numeric → Integer |
Long Text (previously Clob) | Text |
Picklist | Select from List (manual list only) Single Selection |
Precision Decimal (previously BigDecimal) | Numeric → Decimal |
Relationship | ❌ |
Rich Text | Rich Text |
Text (previously String) | Text, Multiple Selection, Grid, Color |