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.

Important
  • 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:

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

    Select the Object storage type and the desired object.

    note

    Only published, active objects appear. You can only connect a form to one object at a time, though you can connect objects 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 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

Object Field TypesCompatible Form Fields
Attachment
BooleanBoolean (checkbox)
DateDate
Decimal (previously Double)Numeric → Decimal
IntegerNumeric → Integer
Long Integer (previously Long)Numeric → Integer
Long Text (previously Clob)Text
PicklistSelect from List (manual list only)
Single Selection
Precision Decimal (previously BigDecimal)Numeric → Decimal
Relationship
Rich TextRich Text
Text (previously String)Text, Multiple Selection, Grid, Color

Capabilities

Product

Contact Us

Connect

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