Issue
- I would like to use already existing Forms, Element Sets and Data Providers on another site, without having to recreate them. What are my options?
Environment
- Liferay DXP 7.1+
Resolution
Forms
Option 1: Forms can be shared from the Global site the following way:
- Create the form in the Global site (Content > Forms)
- Go to another site (e.g.: Liferay DXP)
- Place a Forms portlet on the page
- Go to the "Configuration" menu of the portlet
- Go to the "Scope" tab
- Select "Global"
Result: You will be able to display forms created on the Global site.
Option 2: With the Form's URL
When you publish a form, you will receive a URL from Liferay to access that form (for example http://localhost:8080/web/forms/shared/-/form/33755). That link does not denote the site where the form belongs to. It can be used as the target link for some of the page types offered by DXP 7.1, 7.2 and 7.3:
- Link to URL
- Embedded (note that "Embedded" page type uses iframe)
Follow the steps below to test these approaches:
- Create a new page on a site
- Select the "Embedded/Link to URL" type
- Name the page and click Save
- In the next window, for URL, enter the Form's URL
Result:
- If you selected the type "Embedded", the form will appear on the new Page.
- With the "Link to URL" type, navigating to the new Page will open up the form in the browser tab.
Advantages:
- You can utilize the permission system.
- Pages can be added to navigation menus and are shown in the site as if they were "native".
At the same time, please note that all responses will be associated with the form, therefore, to the site where it lives.
Element Sets
As for Element Sets, unfortunately, it is a current limitation to share them between sites. A workaround for this might be to export a "template form", containing the required element set(s) and import them in another site. A feature request for this functionality has already been raised. Please see the details in this Knowledge Base article: How can I export/import my form's Element Sets?
Data Providers
Data Providers can be shared from the Global site as well. The option to use the Data Provider created in the Global scope will appear when you create the form itself. For example:
- Create a Data Provider on the Global site
- Switch to another site (e.g.: Liferay DXP)
- Go to Content > Forms
- Create a new form
- Add a "Select from list" field to the form
- In the field configuration, under the "Create List menu", select "From Data Provider" option
Result: Notice that in the "Choose a Data Provider" drop-down, the Data Providers from the Global site will appear.
Additional Information
- A feature request ticket has been raised: LPS-79792 Allow user to export/import Element Sets with a portlet export.