Documentation

Using Forms with Objects

Available Liferay DXP 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.

Note

All Forms features are supported for Objects, including rules and validations. However, users 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:

  1. Navigate to the desired Site, open the Site Menu (Site Menu), and go to Content & DataForms.

  2. Click the Add button (Add Button).

  3. Click the Configuration button (Configuration Button) for the new form.

  4. Select both the Object storage type and the specific Object you want to connect with the form.

    This configures the form to store data for the selected Object.

    Select both the Object storage type and the desired Object.

    Note

    Only published, active Objects appear. Also, a form can only be connected to one Object at a time, while Objects can be connected to multiple forms.

  5. 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.

  1. 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.

  2. Click on the Advanced tab.

  3. Select the desired Object field.

    Warning

    When 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.

    In the Advanced tab, select the desired Object field.

  4. Repeat the above process until all desired Object fields are mapped to a form field.

    Note

    An Object field can only be mapped to one form field.

    Map all desired Object fields to the form fields.

  5. Design the form layout. See Forms documentation to learn more about this process.

  6. Once you’ve finished designing the form, click Publish to finish form creation.

    Important

    Before 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.

Use the published form to create Object entries.

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.

Attempting to publish a form with invalid mappings displays an error message.

Field Compatibility Reference

For Liferay 7.4 U20+

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, Single Selection

Precision Decimal (previously BigDecimal)

Numeric → Decimal

Relationship

Rich Text

Rich Text

Text (previously String)

Text, Multiple Selection, Grid, Color