The following form documentation discusses creating basic "no-code" forms using the backend Forms tab. For more advanced code forms with complete form field control, please review the ContentAPI Form examples.
Complex, reusable forms can be created in dotCMS in a few minutes without any knowledge of HTML or Velocity through the use of the Form Content Type. Emailing of the form, form field styling, and form validation all are handled automatically when placing a piece of form content on a page. Follow each of the following steps to create a fully functioning **form, such as the one seen below, in dotCMS.
For form customization options, see the following documentation links:
- Styling Customization Options
- Form Validation (See Custom Field Messaging on Forms)
- Custom Code Field on Forms
- The Submit Content Macro
- Custom Submit Content Forms
- Front End Content Editing
First create a "thank you" HTML page in dotCMS that has a message for front end clients after they have completed submitting the form. Copy/record the relative path to this page for use in your Form Content Type. Now you are ready to begin creating your Form Content Type.
Steps to Creating a Form which submits Content from the Forms tab
- Users who are permissioned to create forms can hover over the Forms & Polls tab and click on "forms" from the drop down menu. From the forms tab users can click on the "Add New Form" button to create a new Form Content Type.
- Title the Form in the Content Type Name field. You will notice the Content Type in the select box has already been set to "Form" as pictured below. Saving the Form Content Type is required before fields can be added to the form.
- After saving the Content Type, four default required hidden fields will be added to the form: Form Title, Form Email, Form Return Page, and Form Host. Click on the pencil icon next to all of these fields except the Form Host, to enter these values to the form. The form host will be recorded in the form submission depending on which host that the front end user submits the form content from.
- Form Title: Title to the form that can be used as a form label in form emails and reporting
- Form Email: is email address of form administrator(s) who will receive notifications after each form submission. More than one email can be added as a comma separated list.
- Form Return Page: The form return page is typically the "thank you" page where front end users are redirected after a successful form submission. Ex: "/mypath/mythankyoupage.html"
- Form Host: The form host is the recorded domain or website the form content was submitted from. This allows one form to be utilized on many different websites but still allows dotCMS to track from which website the form submission came from and even to automatically differentiate user access to form content and direct form email notifications based upon the the site the form submission came from.
- New fields can now be added to the form by clicking on the "+Add New Field" button (see below) Fields of any type can be added to a form. The "label" of each field becomes the label for that field on the form when it is placed on an HTML page. For more information see the documentation on Standard Field Types.
- After placing all the desired fields in the Form Content Type, save the Content Type and visit/create the HTML page where you would like to place the form.
- Click on the "Add Content" button on any container on the HTML page, then click on "Add Form"
- Search/select the form by title to place the form on the page.
- Publish the HTML page using the "Publish Page" button on the HTML page. The form should now be complete and ready for testing - If there are any problems viewing the form from the front end, check the permissions on the form to make sure that the "CMS Anonymous" permission exists on all of the dotCMS objects on the page, including the HTML page itself and the form content. For more information please see the Permissions documentation.
**The dotCMS server must be set up to handle email traffic for the proper submission of front-end forms.