Adding Custom Fields

Many of Liferay’s assets and resources can be extended with custom fields. Adding custom fields can give you greater control and flexibility over your site. You can use custom fields with the following entities:

  • Account Entry
  • Account Group
  • Blogs Entry
  • Bookmarks Entry
  • Bookmarks Folder
  • Calendar Event
  • Discount (Commerce)
  • Document
  • Documents Folder
  • Knowledge Base Article
  • Knowledge Base Folder
  • Message Boards Category
  • Message Boards Message
  • Order (Commerce)
  • Order Item (Commerce)
  • Organization
  • Page
  • Price List (Commerce)
  • Price Modifier (Commerce)
  • Product (Commerce)
  • Product Attachment (Commerce)
  • Product Group (Commerce)
  • Product Link (Commerce)
  • Product Option (Commerce)
  • Product Option Relation (Commerce)
  • Product Option Value (Commerce)
  • Product Option Value Relation (Commerce)
  • Product SKU (Commerce)
  • Product Specification (Commerce)
  • Product Specification Value (Commerce)
  • Role
  • Shipment (Commerce)
  • Site
  • Site Navigation Menu Item
  • User
  • User Group
  • Warehouse (Commerce)
  • Web Content Article
  • Web Content Folder
  • Wiki Page

There are many reasons for using custom fields. Here’s one example.

Max Role Use Case: Suppose you want to limit the number of users that can be assigned to a particular role on your site. To accomplish this, you could create a max-users custom field for the role. Then, create logic to keep track and prevent more users from being added once the set limit was reached.

Adding a Custom Field

  1. Open the Global Menu (Applications Menu icon) and navigate to Control PanelCustom Fields.

  2. Click Role.

    You can choose an asset or resource to add a custom field to.

  3. Click New to add a custom field.

  4. For the above use case, select Input Field as the field type. Enter a Field Name and select Integer as the Data Type.

    Give your custom field a name you can remember, because developers must access it using this name.

  5. Click Save

Note

The Field Name is the identifier stored in your database and the name that is used by the developer to access the custom field.

After creating a custom field, you can find it in the UI of the resource you created it for. In this case, the max-users custom field is now visible for all roles.

  1. Open the Global Menu (Applications Menu icon) and navigate to Control PanelRoles.

  2. Select a role or click Actions (Actions icon) → Edit.

    The custom field is visible in the resource UI.

    Notice the Max Users field at the bottom.

Editing Custom Fields

To edit a custom field, click Actions (Actions icon) next to a custom field and click Edit. These options appear:

Click Actions to edit a custom role.

  • Edit: You can change different aspects of the custom field except its name and type. The configuration options you have depend on the field type you choose.

  • Permissions: You can modify the permissions to allow other users to edit or view a custom field.

  • Delete: You can delete the custom field.

Field Types

There are several different field types you can choose.

There are different field types you can choose from.

  • Text and Numbers
    • Text Area: This field type can collect longer lines of text.

    • Input Field: This field type can collect a string of text, a decimal number, or an integer.

    • Selection

    • Dropdown: This field type can provide a drop-down list of items to select. The list can be text, decimal numbers, or integers.

    • Checkbox: This field type shows a checkbox.

    • Radio: This field type shows a selection of two or more radio buttons.

    • Others

    • Geolocation: This field type collects geolocation information.

    • Date: This field type collects date and time information.

    • True/False: This field type shows a true or false choice.

Capabilities

Product

Contact Us

Connect

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