Have you ever wondered why there’s no Head Circumference field in the form for adding users to Liferay DXP? Probably because most sites based on Liferay DXP don’t need it. If you’re an administrator at the Lunar Resort, however, you certainly need to know your guests’ head circumference so you can provide them with a properly fitting helmet.
Many of Liferay DXP’s assets and resources let you add new fields to their edit forms. Here’s the complete list:
- Blogs Entry
- Calendar Event
- Documents Folder
- Knowledge Base Article
- Knowledge Base Folder
- Message Boards Category
- Message Boards Message
- User Group
- Web Content Article
- Web Content Folder
- Wiki Page
To add custom fields, find the Custom Fields entry beneath the Control Panel’s Configuration heading.
To add a custom field to one of the listed entities,
Choose a resource by clicking on it.
Click the add () button.
Choose a field type: Text Area, Input Field, Dropdown, Checkbox, Radio, Geolocation, Date, True/False.
Add a name that’s used as a key for accessing the field programmatically.
Choose the Data Type of field and set any advanced properties.
Once you have a custom field for a resource, go find it in the UI of the resource. First find the UI location for the resource, and all its custom fields are displayed in a Custom Fields panel. For example, consider the Users UI:
Navigate to Control Panel → Users and Organizations. Click on a User to open the Edit User form and scroll down to find your custom field.
You can also leverage your custom field in Content Pages and Display Page Templates. See Editable Elements for more information.
You can’t change the key or field type of a custom field, but you can delete it and create a new one if necessary.
Edit an individual custom field’s permissions by clicking the field’s kebab menu (), then Permissions. Permission can be granted or removed for these actions:
Custom fields make many of Liferay DXP’s entities extensible directly from the administrative user interface. Use them as is or combine them with some back-end code, and you have yet another powerful, flexible feature at your disposal. As they’re fond of saying at The Lunar Resort, “The sky is certainly not the limit.”