Recipe
Published August 06, 2024

Building Multi-Step Forms With Liferay DXP Objects

While we make every effort to ensure this Recipe is accurate, it may not always reflect the most recent updates or official guidelines. We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Introduction

This recipe guides you through the basic steps to build a multi-step form.
 

Prerequisites

  • Liferay DXP environment

  • An object definition with fields

  • A user who has access and control to create and manage objects, display pages, and the ability to edit pages

Steps

  1. Open the Global Menu, go to Control Panel tab, and click Objects.

  2. Select your object.

  3. In your object's details menu, enable the Allow Users to Save Entries as Draft toggle button.

  4. (Optional) In your object's details menu, select Object for the Panel Link.

  5. Open the Site Menu, expand Design, and click Page Templates.

  6. Go to the Display Page Templates tab to create the display page templates.

  7. Click New to create a new display page template.

  8. Select the desired master page.

  9. Name it Success Page - Feedback Survey and under Content Type select Survey.

  10. Click Save.

  11. Click Publish.

  12. Click New to create a new display page template.

  13. Select the desired master page.

  14. Name it Step 2 - Feedback Survey and under Content Type select Survey.

  15. Click Save.

  16. Drag and drop a container element onto the new page.

  17. Change the container width in the right panel to Fixed Width.

  18. Drag a form container inside the first container, and map it to the Survey object.

  19. Go to the form container's General tab on the right panel.

  20. Under Success Action dropdown select Go to Entry Display Page and under Display Page select Success Page - Feedback Survey.

  21. It will populate with all object fields. Delete the following fields: `First Name`, `Last Name`, and `What is your role?`.

  22. Note

    Deleting required fields generates a warning. All required fields must be present within the multi-step form for a submission to be valid.

  23. Select the Submit button, open the Styles tab, and set the top margin to 1rem.

  24. Click Publish.

  25. A warning message will appear. Click Publish again to proceed.

  26. Click the Success Page - Feedback Survey template draft to begin editing it.

  27. Drag and drop a container element onto the new page.

  28. Change the container width in the right panel to Fixed Width.

  29. Drag and drop a heading element into the container, and change the Heading Level to H2.

  30. Navigate to the Styles tab on the right panel and select the Align Center option to center the text.

  31. To modify the heading, double-click the Heading Example text and replace it with `Thank you!`.

  32. Drag and drop a new heading element below the existing heading within the container. Adjust the Heading Level to H3.

  33. Navigate to the Styles tab on the right panel and select the Align Center option to center the text.

  34. Click the heading's element-text, and map the field to Survey → First Name.

  35. Drag and drop a button element below the second header and apply the Outline Primary option style.

  36. Navigate to the Styles tab on the right panel and select the Align Center option to center the text.

  37. Apply a margin-top of 1rem to the button.

  38. Double-click the Submit button to edit its text, then replace the existing text with Return to Home.

  39. In the Link tab, select Page as the link type and choose the Home page as the destination.

  40. Click Publish.

  41. Now that you have all display page templates created, go to the page where you want to host the form.

  42. Click the Edit icon on the top right corner of your screen.

  43. Drag and drop a container element onto the desired page.

  44. In the right panel, change the container width to Fixed Width.

  45. Drag and drop a form container inside the first container, and map it to the Survey object.

  46. Go to the form container's General tab on the right panel.

  47. Under Success Action dropdown choose Go to Entry Display Page and select Step 2 - Feedback Survey as the Display Page.

  48. It will populate with all object fields. Delete the following fields: `How did you hear about these webinars?`, `Tell us about your experience with the webinars`, and `Would you recommend these webinars to others?`.

  49. Select the Submit button and change the Submitted Entry Status to Draft.

  50. In the Styles tab apply a margin-top of 1rem to the button.

  51. Double-click the Submit button and rename it to `Next`.

  52. Click Publish.

  53. A warning message will appear. Click Publish again to proceed.

  54. To test the form, navigate to the page where it was created and complete the initial fields.

  55. Click Next to proceed.

  56. Once you're redirected to the second page, fill out the fields and click Publish.

  57. On the Success Page, the first name typed previously should be under the "Thank You!" message.

  58. Open the Global Menu, go to Control Panel tab, and click Survey to see all feedback survey responses.

Conclusion

Congratulations! You have successfully completed this recipe on building multi-step business forms.

Tips

Tips

If you encounter the "Thank you. Your information was successfully received." message, review the form container settings. Ensure the Success Action is set to "Go to Entry Display Page" and the designated Display Page is correctly specified.

Recipe
20 Minutes

Capabilities

Product

Contact Us

Connect

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