Liferay DXP’s forms can be built to gather large amounts of data. These larger forms are organized into easily navigable sections and categories. This is possible thanks to the Form Navigator framework. As an administrator, you may wish to hide certain form sections. Maybe you want to show certain sections when creating new content, but hide other sections when someone updates that content. Perhaps you want to reorder form sections. Since Liferay DXP 7.0 Fix Pack 14 and Liferay Portal CE GA4, all these configuration options are possible via the Form Navigator Configuration system setting.
This tutorial covers how to use the Form Navigator Configuration system setting to control which form categories and sections are visible.
Get started by retrieving the available entry keys and categories next.
Form Navigator configurations contain the following information:
- Form ID
- Category (if there is one)
- Context (optional)
- Section entry keys
You can retrieve this information easily, thanks to the following Gogo shell command:
formNavigator:getPossibleConfigurations [optional form ID]
This command can be run two ways:
- With no form ID: lists every form with all possible categories and entries
- With a form ID: lists all categories and entries for the given form
For example, running the Gogo shell command
formNavigator:getPossibleConfigurations sites.form results in the output
shown in the figure below:
You can read more about using the GoGo shell in the Felix GoGo Shell Reference Guide.
Now that you have the form ID(s) and available categories and entry keys, you can create a Form Navigator configuration. As mentioned above, Form Navigator configurations can contain an optional context. Form contexts are covered next.
A Form Navigator context refers to the context in which a form is being viewed. Form contexts allow you to control dynamically which form sections are displayed. The following contexts are available by default:
add: Denotes that the form is being viewed when new content is being created.
For example, you could use the
add context to specify which form sections are
visible when someone creates a new site.
update: Denotes that the form is being viewed when content is being edited.
For example, you could use the
update context to specify which form sections
are visible when someone edits a web content article.
You can create additional contexts by following the steps covered in the Creating Form Navigator Contexts tutorial.
Now that you have the form ID(s), available categories and entry keys, and you understand Form Navigator contexts, you can configure the Form Navigator system settings next.
Open the Control Panel and go to Configuration → System Settings. Select Foundation → Form Navigator Configuration.
Follow these steps to create a new configuration entry:
Click the Add button to bring up the Form Navigator Configuration Form.
Enter the Form Navigator ID you retrieved from the Gogo shell command (
Next, enter the Form Navigator entry keys. Enter an optional context (
update), category (if there is one), and a comma-separated list of Form Navigator entry keys for each section that you want to display. For example, the value below hides the Documents and Media section under the General tab for the Sites form:
The value below provides a configuration for the Sites form when editing a site:
Here is an example configuration for the web content form that has no categories and several entries:
Here is the same configuration with an
The order of the entry keys specifies the order in which the sections are displayed in the form, from top to bottom. To reorder sections, place the comma-separated list of entry keys in the order you want the sections to appear in the form. You can also move a section from one category to another by adding the entry key to the category in which you want the section to appear.
Save your changes.
Now you know how to control the visibility of your Form Navigator form categories and sections!