Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: MOTION-157

...

HTML Wrap
clearboth
width225px
alignright
classmenu

Related topics:

Excerpt
hiddentrue

Supported with EE

The Form module allows you to create Web forms that visitors can fill in. The module provides components for easy creation of standard forms, like contact forms. You can group related form elements such as address fields together visually. Form data can be validated using configurable validators. By default, submitted form data is sent by email. You can process form data with pluggable data processors which allow customization without changing the Magnolia core system. Magnolia forms are fully HTML5 compliant.

...

  1. Create a new page based on the template that contains the Form component (created in 1. above).
  2. Open the page, add the Form component and configure the form settings. Form settings define the title and name of the form, and where the collected information should be submitted.
    Image Removed
  3. Add a fieldset to the form.
    Image Removed

    Info

    You can have multiple field sets in one form. This helps to groups them visually. For example contact details in one set and feedback message in another etc.

  4. Add a field set.
    Image Removed
  5. Add fields inside the field set.
    Image Removed
  6. View the form.
    Image Removed

Creating forms for handling personal data

With Magnolia you can create forms for the purposes of handling personal data, for example for the requirements of General Data Protection Regulation (GDPR).

Magnolia provides the following pre-configured GDPR-related form templates as samples you can build on:

...

Store data form

...

Double opt-in forms.

See an example of creating a form with double opt-in functionality on the Creating a GDPR-compliant form page.

...

Confirm data form

...

Get visitor data form

...

Forget me form

...

Delete visitor form

...

  1. Create a new page based on the template that contains the Form component (created in 1. above).
  2. Open the page, add the Form component and configure the form settings. Form settings define the title and name of the form, and where the collected information should be submitted.
    Image Added
  3. Add a fieldset to the form.
    Image Added

    Info

    You can have multiple field sets in one form. This helps to groups them visually. For example contact details in one set and feedback message in another etc.

  4. Add a field set.
    Image Added
  5. Add fields inside the field set.
    Image Added
  6. View the form.
    Image Added

Creating forms for handling personal data

With Magnolia you can create forms for the purposes of handling personal data, for example for the requirements of General Data Protection Regulation (GDPR).

Magnolia provides the following pre-configured GDPR-related form templates as samples you can build on:

Sample form (GDPR)Use to createProvided by

Store data form

Double opt-in forms.

See an example of creating a form with double opt-in functionality on the Creating a GDPR-compliant form page.

privacy-sample module

Confirm data form

Get visitor data form

Forms where the user can request a zipped report listing their personal data stored by the site.privacy-form module

Forget me form

Forms where the user can request deletion of their personal data.

Delete visitor form

Forms where the user can confirm a request for deletion of the user's personal data

Personal data form processors

To implement the above functions, the magnolia-privacy module provides the following form processors:

Personal data form processors

To implement the above functions, the magnolia-privacy module provides the following form processors:

  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.AddConsentFormProcessor
    renderTypeasynchronous
    : Updates a visitor's consent.
    • Javadoc resource link
      classNameinfo.magnolia.privacy.form.processor.JcrStoreFormProcessor
      renderTypeasynchronous
      : Extends the functionality of the AddConsentFormProcessor processor. It also stores the data into a JCR workspace. The data is stored in an intermediate workspace so that the data cannot be used unless the visitor confirms consent. Under the processor define:
      • workspace -  the name of the intermediate workspace.
      • nodeNameProperty -  the node name of the data to be stored.
      • nodeType - the node type of the data to be stored.
      • rootPath - the path to the node (default is "/").
    • Javadoc resource link
      classNameinfo.magnolia.privacy.form.processor.JcrMoveFormProcessor
      renderTypeasynchronous
      : Moves data from the intermediate workspace to the target workspace. Configure the intermediate and target workspaces under the processor using the sourceWorkspace and targetWorkspace properties.
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.ConfirmConsentFormProcessor
    renderTypeasynchronous
    : Confirms a visitor's consent.
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.GetVisitorDataFormProcessor
    renderTypeasynchronous
    : Collects all data belonging to a visitor and provides a weblink where the visitor can download this data.
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.AddConsentFormProcessorDeleteVisitorFormProcessor
    renderTypeasynchronous
    :  Updates Requests the deletion of all a visitor's consentdata (via a deletionId).
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.
    JcrStoreFormProcessor
    ConfirmVisitorDeletionFormProcessor
    renderTypeasynchronous
    : Extends the functionality of the AddConsentFormProcessor processor. It also stores the data into a JCR workspace. The data is stored in an intermediate workspace so that the data cannot be used unless the visitor confirms consent. Under the processor define:
    • workspace -  the name of the intermediate workspace.
    • nodeNameProperty -  the node name of the data to be stored.
    • nodeType - the node type of the data to be stored.
    • rootPath - the path to the node (default is "/").
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.JcrMoveFormProcessor
    renderTypeasynchronous
    : Moves data from the intermediate workspace to the target workspace. Configure the intermediate and target workspaces under the processor using the sourceWorkspace and targetWorkspace properties.
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.ConfirmConsentFormProcessor
    renderTypeasynchronous
    : Confirms a visitor's consent.
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.GetVisitorDataFormProcessor
    renderTypeasynchronous
    : Collects all data belonging to a visitor and provides a weblink where the visitor can download this data.
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.DeleteVisitorFormProcessor
    renderTypeasynchronous
    : Requests the deletion of all a visitor's data (via a deletionId).
  • Javadoc resource link
    classNameinfo.magnolia.privacy.form.processor.ConfirmVisitorDeletionFormProcessor
    renderTypeasynchronous
    : Confirms the deletion request.

See GDPR and forms too.

Creating a multistep form

Info

See an example multistep form on the "Book your tour" page of the Travel demo.

Splitting a large form into multiple steps allows the visitor to focus on one step at a time. The substeps are detected automatically. Visitors can move forward and backwards between steps without losing entered data. Each step is validated individually. The form module also allows users to upload files, but the upload field should only be included as the last step of the process.

Add the Form Step component to an area of a template.
Example: Adding formStep component to main area in a new template.

...

Localtab
activetrue
titleYAML file
Code Block
languagejs
title/my-module/templates/pages/form.yaml
templateScript: /my-module/templates/pages/formStep-page-template.ftl
renderType: freemarker
visible: true
title: Form Step Template
dialog: my-module:pages/form
areas:
  main:
    availableComponents:
      form:
        id: form:components/formStep

...

titleJCR node

...

heading0
multiplefalse
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

...

Mgnl f
my-module

...

Mgnl f
templates

...

Mgnl f
pages

...

Mgnl n
formStep

...

Mgnl n
areas

...

Mgnl n
main

...

Mgnl n
availableComponents

...

Mgnl n
formStep

...

Mgnl p
id

...

form:components/formStep

...

Mgnl p
dialog

...

my-module:pages/form

...

Mgnl p
renderType

...

freemarker

...

Mgnl p
title

...

Form Step Template

...

Mgnl p
templateScript

...

/my-module/templates/pages/formStep-page-template.ftl

...

Mgnl p
visible

...

true

...

  1. Configure the form settings
  2. Add a field set component
  3. Add fields inside the field set. The Submit button field will automatically navigate to the next step. Conditional steps can be set in the Next step condition component.

    Image Removed

...

  1. Add field sets and fields on the substep forms. Submit button fields will automatically navigate to subsequent or conditional steps and the final button will submit the form.
    Image Removed  Image Removed  Image Removed

Configuring form settings

Form settings are configured in the Form component.

Form tab

...

Field

...

Description

...

Title

...

Title displayed above the form. For example "Contact Us".

...

Form name

...

Internal name that allows you to reference the form by name, for example from JavaScript.

...

Text

...

Introductory text displayed below the form title.

...

Marker for required fields

...

Character displayed next to required fields. Asterisk by default.

...

Text for required symbol

...

Text that explains what the required marker means, displayed near the top of the form. For example "Required fields".

...

Step-by-step navigation

...

When checked displays step-by-step breadcrumb navigation that allows the user to navigate the steps of multistep forms.

Submit settings tab

...

Field

...

Description

...

Error title

...

Title displayed when an error occurs, for example "There was a problem with your booking."

...

Success title

...

Title displayed when the form is submitted successfully, for example "Your tour is booked"

...

Text

...

Text displayed when form is submitted successfully, for example "Details are on their way to your inbox."

...

Page displayed after submission

...

Select a page to display after submission. If no page is selected, the user stays on the current page and the success title and text are displayed instead.

...

Track mail

...

Logs the information submitted in the form to magnolia-form.log file.
(warning) Make sure the trackEMail form processor is also enabled. See Logging form data.

Email tab

...

Field

...

Description

...

From

...

Email address displayed in the From field of the outgoing message. This can be any address as it is not the account used to send the mail. The mail is sent using the account in SMTP configuration .

...

To

...

Email address the data is sent to. You can use form field names with Freemarker tags. Typically you would ask the submitting user for their email address on the form and repeat it here with a Freemarker tag such as ${email} assuming the email field is named email.

...

Subject

...

Email subject line. You can use form field names with Freemarker tags such as ${subject}.

...

Available fields for Freemarker syntax

...

Form field names that can be used in Freemarker tags.

...

Type

...

Radio button to select the message type for the email body.

...

text

...

Displays a text field to compose the email template. You can use form field names with Freemarker tags such as ${subject} and ${message} to write the data collected on the form into the message.

...

html

...

Confirmation email tab

...

Field

...

Description

...

Send confirmation

...

Sends a confirmation mail to the submitting user.
(warning) Make sure the SendConfirmationEMailProcessor form processor is also enabled.

...

From

...

Email address displayed in the From field of the outgoing message. You might want to use a customer support address here in case the user has further questions or a no-reply address. You can use form field names with Freemarker tags.

...

To

...

Email address the data is sent to. You can use form field names with Freemarker tags such as ${email}.

...

Subject

...

Email subject line, for example "We have received your feedback." You can use form field names with Freemarker tags such as ${subject}.

...

Available fields for Freemarker syntax

...

Form field names that can be used in Freemarker tags.

...

Mail type

...

Radio button to select the message type. For code and text you can use form field names with Freemarker tags such as ${subject} and ${message} to write the data collected on the form into the message. This can be a simple acknowledgement that data was submitted or you can summarize the collected data.

...

code

...

text

...

Displays a Text field to compose the email template. 

...

page

...

  • Confirms the deletion request.

See GDPR and forms too.

Creating a multistep form

Info

See an example multistep form on the "Book your tour" page of the Travel demo.

Splitting a large form into multiple steps allows the visitor to focus on one step at a time. The substeps are detected automatically. Visitors can move forward and backwards between steps without losing entered data. Each step is validated individually. The form module also allows users to upload files, but the upload field should only be included as the last step of the process.

  1. Add the Form Step component to an area of a template.
    Example: Adding formStep component to main area in a new template.

    Code Block
    languagejs
    title/my-module/templates/pages/form.yaml
    templateScript: /my-module/templates/pages/formStep-page-template.ftl
    renderType: freemarker
    visible: true
    title: Form Step Template
    dialog: my-module:pages/form
    areas:
      main:
        availableComponents:
          form:
            id: form:components/formStep
  2. Create a new page based on a template that contains the Form component. This is the first page of the form.
    1. Configure the form settings
    2. Add a field set component
    3. Add fields inside the field set. The Submit button field will automatically navigate to the next step. Conditional steps can be set in the Next step condition component.

      Image Added

  3. Create subpages based on the template that contains the Form Step component (created in 1. above) for the subsequent steps of the form.
    1. Add field sets and fields on the substep forms. Submit button fields will automatically navigate to subsequent or conditional steps and the final button will submit the form.
      Image Added  Image Added  Image Added

Configuring form settings

Form settings are configured in the Form component.

Form tab

Field

Description

Title

Title displayed above the form. For example "Contact Us".

Form name

Internal name that allows you to reference the form by name, for example from JavaScript.

Text

Introductory text displayed below the form title.

Marker for required fields

Character displayed next to required fields. Asterisk by default.

Text for required symbol

Text that explains what the required marker means, displayed near the top of the form. For example "Required fields".

Step-by-step navigation

When checked displays step-by-step breadcrumb navigation that allows the user to navigate the steps of multistep forms.

Submit settings tab

Field

Description

Error title

Title displayed when an error occurs, for example "There was a problem with your booking."

Success title

Title displayed when the form is submitted successfully, for example "Your tour is booked"

Text

Text displayed when form is submitted successfully, for example "Details are on their way to your inbox."

Page displayed after submission

Select a page to display after submission. If no page is selected, the user stays on the current page and the success title and text are displayed instead.

Track mail

Logs the information submitted in the form to magnolia-form.log file.
(warning) Make sure the trackEMail form processor is also enabled. See Logging form data.

Email tab

Field

Description

From

Email address displayed in the From field of the outgoing message. This can be any address as it is not the account used to send the mail. The mail is sent using the account in SMTP configuration .

To

Email address the data is sent to. You can use form field names with Freemarker tags. Typically you would ask the submitting user for their email address on the form and repeat it here with a Freemarker tag such as ${email} assuming the email field is named email.

Subject

Email subject line. You can use form field names with Freemarker tags such as ${subject}.

Available fields for Freemarker syntax

Form field names that can be used in Freemarker tags.

Type

Radio button to select the message type for the email body.

text

Displays a text field to compose the email template. You can use form field names with Freemarker tags such as ${subject} and ${message} to write the data collected on the form into the message.

html

Displays a Rich text field to compose the email template. You can use markup that will be escaped.

Confirmation email tab

Field

Description

Send confirmation

Sends a confirmation mail to the submitting user.
(warning) Make sure the SendConfirmationEMailProcessor form processor is also enabled.

From

Email address displayed in the From field of the outgoing message. You might want to use a customer support address here in case the user has further questions or a no-reply address. You can use form field names with Freemarker tags.

To

Email address the data is sent to. You can use form field names with Freemarker tags such as ${email}.

Subject

Email subject line, for example "We have received your feedback." You can use form field names with Freemarker tags such as ${subject}.

Available fields for Freemarker syntax

Form field names that can be used in Freemarker tags.

Mail type

Radio button to select the message type. For code and text you can use form field names with Freemarker tags such as ${subject} and ${message} to write the data collected on the form into the message. This can be a simple acknowledgement that data was submitted or you can summarize the collected data.

code

Displays a Code field (includes syntax highlighting) to compose the email template.

text

Displays a Text field to compose the email template. 

page

A page in the site that the user is sent to after successful submission.

Field sets

The purpose of a field set is to group fields that logically belong together:

  • Before you can add any fields on the form you need to add at least one field set component.
  • You can add as many field sets as necessary.
  • Use the Title field to distinguish field sets or include introductory text.
  • Individual fields components are added as subcomponents in a field set.
  • Component definition: formGroupFields

Image Added

Fields

Field components are added within a field set.

Available fields:

FieldDescriptionImage
Input
  • Single line text input or text area.
  • Maximum input length option.
  • Component definition: formEdit.

Advanced options: Not all input types and attributes are supported in all browsers.

TypesHTML5-compliant input type.

Color

<input type = color> . To select a color from a pop-up color picker
Image Added

Email

<input type = email>. Email field. Most browsers automatically validate content. Additionally, you can use E-mail validator.
Image Added

Password

<input type = password> . Password field. The characters are masked with asterisks or circles.
Image Added

Search

<input type = search>. Search field. Behaves like a regular text field.

Text

<input type = text>.  Standard text field.

Url

<input type = url>. For fields that should contain a URL address. Most browsers validate automatically
Image Added
Attributes

Placeholder

Hint that describes the expected value. 
Image Added

Pattern

Regular expression that the input value is checked against. For example [A-Za-z]{3} for a three letter country code.


(warning) Please note that this attribute has no effect at this time. We are aware of this issue and working on a bugfix for this.

Jira
serverMagnolia - Issue tracker
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId500b06a6-e204-3125-b989-2d75b973d05f
keyMGNLFORM-296


As a temporary workaround, you can configure the regex expression as a separate validator for the field under

/modules/form/config/validators .

Image Added

Pattern description

Use the field description to help guide the user instead.

Read only

Boolean attribute that sets the field as read-only.User cannot enter input but can tab to it, highlight it, and copy from it.

Disabled

Boolean attribute that disables the input field. Field is unusable and unclickable. Typically used to prevent user from entering input until another condition is met.
Image Added

Autofocus

Boolean attribute that places the cursor in the focused field on page load.

Autocomplete

Enables autocomplete which allows the browser to predict the value based on earlier typed values. Submit information and then reload the page to test.
Image Added

Image Added

Number or date
  • Number or date field.
  • Maximum input length option.
  • Component definition: formNumber (extends formEdit).

Advanced options: Not all input types and attributes are supported in all browsers.

TypesHTML5-compliant input type.

Date

<input type = date>. To enter or select a date.
Image Added

Datetime

<input type = datetime>. To enter or select a date and time with a timezone. 

(warning) This type is no longer supported by the latest HTML standards, see

Modern browsers may differ in how they render this type, most of them displaying a simple textfield instead.

Image Added

Datetime-local

<input type = datetime-local>. To enter or select a date and time (no time zone).
Image Added

Month

<input type = month>. To enter or select a month and year.
Image Added

Number

<input type = number>. To enter or select a numeric value.
Image Added

Phone number

<input type = tel>. For fields that should contain telephone numbers. Only supported in Safari 8.

Range

<input type = range>. For fields that should contain a value within a range. 
Image Added

Time

<input type = time>. To select a time (no time zone).
Image Added

Week

<input type = url>. To select a week and year.
Image Added
Attributes

Read only

See Input field.

Disabled

See Input field.

Autofocus

See Input field.

Autocomplete

See Input field.

Minimum

Minimum value for the field.

Maximum

Maximum value for the field.

Step

Number intervals for the field, for example if step="3", legal numbers could be -3, 0, 3, 6, etc..

Image Added

Text field group
  • Groups text fields next to each other.
  • The Group dialog has a single field that does not display on the page. Assign this name to reference the group with FreeMarker tags.
  • The subcomponents are Text fields, i.e. Input fields without advanced options.
  • Component definition: formGroupEdit that nests  formGroupEditItem  components.

Image Added

Selection
  • Checkbox, select and radio buttons.
  • Multiple selection, default value and orientation options.
  • Component definition: formSelection.

Image Added

File
  • Upload file component.
  • In multistep forms this is only available on the last step.
  • Component definition: formFile.

Image Added

Submit button
  • Submits the form.
  • Can be labelled as required.
  • Cancel button and Back button (mulitstep forms) options.
  • Component should be added at the end of the form.
  • Component definition: formSubmit.

Image Added

Hidden
  • Single hidden line input or text area.
  • Does not display on the page.
  • Used to pass on values to the form processors in the same way as other data entered by a user.
  • Component definition: formHidden.

Honeypot
  • This is an invisible field that you can add to the page to intercept bot attacks.
  • Component definition: formHoneypot.

Image Added

Form summary
  • Displays a table with parameters and/or values of the steps in a multistep form.
  • Component definition: formSummary


Info

Users are allowed to enter HTML-like characters such as ampersand (&) into fields. Use the noHTML validator to prevent this. You can control HTML escaping with the  escapeHtml  property in the  component definition

Conditional steps

The Condition list component provides optional, additional business logic to a multistep form

  • The component is added automatically after a Submit button field, as an optional area.
  • Allows you to set conditions for subsequent steps in a multistep form.
  • Allows you to define the page the user is directed to, dependent on their entry in a former step.

Field validators

Validators are used to ensure that form data is entered in the correct format. For example, an email address should follow established syntax where a local part is followed by the @ character and a domain: john.doe@example.com.

  Choose a validator for appropriate fields in the Validation field. 

  Image Added

 When field validation passes, the value is submitted. When field validation fails, the field is highlighted in red and when the user attempts to submit the form a notification message identifies the problem. 

 Image Added

Validators are configured in /modules/form/config/validators/:

Image Added

Properties:

validators

required

Validator configuration node

<validator name>

required

Name of the validator.

class

required

Validator class that performs the validation.

<validator properties>

required/optional

Available properties depend on the validator class.

  Validator configurations:

email

Value needs to be a valid email address.

Properties:

class

required

info.magnolia.module.form.validators.RegexValidator (

Javadoc
0info.magnolia.module.form.validators.RegexValidator
)

expression

required

Validity is checked with regular expression (^([a-zA-Z0-9_\.\-+])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$).

number

Value needs to be a number, specifically an integer. No decimals separated with period or comma or fractions are accepted.

Properties:

class

required

info.magnolia.module.form.validators.RegexValidator (

Javadoc
0info.magnolia.module.form.validators.RegexValidator
)

expression

required

Validity is checked with regular expression ^[0-9]*$.

noHTML

Value cannot any have HTML markup. This ensures that users can only enter plain text. Creating links and formatting text is prevented.

Property:

class

required

info.magnolia.module.form.validators.NoHTMLValidator (

Javadoc
0info.magnolia.module.form.validators.NoHTMLValidator
). Custom class that checks for the presence of angle brackets (< >).

password

Validates that the password entered into two password fields match. Used to eliminate typos.

Property:

class

required

info.magnolia.module.form.validators.PasswordValidator (

Javadoc
0info.magnolia.module.form.validators.PasswordValidator
). The fields should be named password and passwordConfirmation.

fileUpload

Validates against a list of allowed mime types and a max file size.

Properties:

class

required

info.magnolia.module.form.validators.FileUploadValidator (

Javadoc
0info.magnolia.module.form.validators.FileUploadValidator
).

maxFileSize

optional, default is 10485760

Max file upload size

allowedMimeTypes

optional

Content node for list of allowed mimeTypes. Add a property for each additional type. By default, application/pdf, image/gif, image/jpeg, image/jpg and image/png are allowed.

empty

No validation. Used for Honeypot field only.  

Properties:

class

required

info.magnolia.module.form.validators.RegexValidator (

Javadoc
0info.magnolia.module.form.validators.RegexValidator
).

expression

required

- (dash/null)

username

Verifies that the entered username does not exist in the system. This validator is added by the Public User Registration (PUR) module.

class

required

info.magnolia.module.publicuserregistration.validators.UsernameValidator (

Javadoc
0info.magnolia.module.publicuserregistration.validators.UsernameValidator
).

uniqueEmail

Verifies that the entered email does not exist in the system. This validator is added by the Public User Registration (PUR) module.

class

required

info.magnolia.module.publicuserregistration.validators.UniqueEmailValidator (

Javadoc
0info.magnolia.module.publicuserregistration.validators.UniqueEmailValidator
).

Form processors

Form processors configured in the module are responsible for sending submitted form data by email. The processors are executed when the form is submitted. The email content corresponds with the settings configured in the relevant tabs of the Form component.

Processors are configured in /modules/form/templates/components/form/formProcessors.

Image Added

Properties:

formProcessors

required

Form processor node.

<form processor name>

required

Name of the form processor.

class

required

  • info.magnolia.module.form.processors.SendContactEMailProcessor (
    Javadoc resource link
    classNameinfo.magnolia.module.form.processors.SendContactEMailProcessor
    renderTypeasynchronous
    ): Sends form data in email to the address specified in the To field. The processor extracts values from the From, To, Subject and Text fields and creates an email message in plain text or HTML format depending on form settings. Any uploaded files are sent as attachments.   
  • info.magnolia.module.form.processors.SendConfirmationEMailProcessor (
    Javadoc resource link
    classNameinfo.magnolia.module.form.processors.SendConfirmationEMailProcessor
    renderTypeasynchronous
    ): Sends a confirmation email. The processor first verifies if the Send confirmation checkbox is checked and sends a message to the address specified in the To field. By default, this processor is not enabled. This is the case even if the Send confirmation checkbox is checked in form settings. To enable it, add an enabled property under the processor and set the value to true.
  • info.magnolia.module.form.processors.TrackEmailProcessor (
    Javadoc resource link
    classNameinfo.magnolia.module.form.processors.TrackEmailProcessor
    renderTypeasynchronous
    ): Writes the content of the submitted form to magnolia-form.log file if the Track Mail checkbox is checked. By default, this processor is not enabled. This is the case even if the Track Mail checkbox is checked in form settings. To enable it, add an enabled property under the processor and set the value to true.

enabled

optional , default is false

Enables and disables the processor

loggerName

required

The logger name. Only relevant for trackEmail processor.

Creating a custom form processor

The three example form processors above send the form data in email, but you can write a custom form processor to do almost anything. If you need to store the data in a database or process it in another way, write your own form processor. You can also try the Form2DB App that is a community developed app that saves form data via form processor into the JCR and allows for export to XLS.

Info

Create a new form component definition for your custom processor. If you simply add the custom processor to the default component definition it will be executed for all forms.

For more examples see Form processors in the PUR module

You can also create a form processor with server-side JavaScript.

Form components

The form components are configured in /modules/form/templates/components

Image Added

Field sets

The purpose of a field set is to group fields that logically belong together:

  • Before you can add any fields on the form you need to add at least one field set component.
  • You can add as many field sets as necessary.
  • Use the Title field to distinguish field sets or include introductory text.
  • Individual fields components are added as subcomponents in a field set.
  • Component definition: formGroupFields

Image Removed

Fields

Field components are added within a field set.

Available fields:

...

  • Single line text input or text area.
  • Maximum input length option.
  • Component definition: formEdit.

Advanced options: Not all input types and attributes are supported in all browsers.

...

Color

...

Image Removed

...

Email

...

Image Removed

...

Password

...

Image Removed

...

Search

...

Text

...

Url

...

Image Removed

...

Placeholder

...

Image Removed

...

Pattern

Regular expression that the input value is checked against. For example [A-Za-z]{3} for a three letter country code.

(warning) Please note that this attribute has no effect at this time. We are aware of this issue and working on a bugfix for this.

Jira
serverMagnolia - Issue tracker
columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
serverId500b06a6-e204-3125-b989-2d75b973d05f
keyMGNLFORM-296

As a temporary workaround, you can configure the regex expression as a separate validator for the field under

/modules/form/config/validators .

...

Image Removed

...

Pattern description

...

Read only

...

Disabled

...

Image Removed

...

Autofocus

...

Autocomplete

...

Image Removed

...

Image Removed

...

  • Number or date field.
  • Maximum input length option.
  • Component definition: formNumber (extends formEdit).

Advanced options: Not all input types and attributes are supported in all browsers.

...

Date

...

Image Removed

...

Datetime

...

<input type = datetime>. To enter or select a date and time with a timezone. 

(warning) This type is no longer supported by the latest HTML standards, see

Modern browsers may differ in how they render this type, most of them displaying a simple textfield instead.

...

Image Removed

...

Datetime-local

...

Image Removed

...

Month

...

Image Removed

...

Number

...

Image Removed

...

Phone number

...

Range

...

Image Removed

...

Time

...

Image Removed

...

Week

...

Image Removed

...

Read only

...

Disabled

...

Autofocus

...

Autocomplete

...

Minimum

...

Maximum

...

Step

...

Image Removed

...

  • Groups text fields next to each other.
  • The Group dialog has a single field that does not display on the page. Assign this name to reference the group with FreeMarker tags.
  • The subcomponents are Text fields, i.e. Input fields without advanced options.
  • Component definition: formGroupEdit that nests  formGroupEditItem  components.

...

Image Removed

...

  • Checkbox, select and radio buttons.
  • Multiple selection, default value and orientation options.
  • Component definition: formSelection.

...

Image Removed

...

  • Upload file component.
  • In multistep forms this is only available on the last step.
  • Component definition: formFile.

...

Image Removed

...

  • Submits the form.
  • Can be labelled as required.
  • Cancel button and Back button (mulitstep forms) options.
  • Component should be added at the end of the form.
  • Component definition: formSubmit.

...

Image Removed

...

  • Single hidden line input or text area.
  • Does not display on the page.
  • Used to pass on values to the form processors in the same way as other data entered by a user.
  • Component definition: formHidden.

...

  • This is an invisible field that you can add to the page to intercept bot attacks.
  • Component definition: formHoneypot.

...

Image Removed

...

  • Displays a table with parameters and/or values of the steps in a multistep form.
  • Component definition: formSummary
Info

Users are allowed to enter HTML-like characters such as ampersand (&) into fields. Use the noHTML validator to prevent this. You can control HTML escaping with the  escapeHtml  property in the  component definition

Info

(warning) 5.4.4+ Password field is deprecated. Use two Input fields with input type Password instead. Validate the second field using the Password validator.

Conditional steps

The Condition list component provides optional, additional business logic to a multistep form

  • The component is added automatically after a Submit button field, as an optional area.
  • Allows you to set conditions for subsequent steps in a multistep form.
  • Allows you to define the page the user is directed to, dependent on their entry in a former step. 

    Hide block

    Image Removed

    Image Removed

Field validators

Validators are used to ensure that form data is entered in the correct format. For example, an email address should follow established syntax where a local part is followed by the @ character and a domain: john.doe@example.com.

  Choose a validator for appropriate fields in the Validation field. 

  Image Removed

 When field validation passes, the value is submitted. When field validation fails, the field is highlighted in red and when the user attempts to submit the form a notification message identifies the problem. 

 Image Removed

Validators are configured in /modules/form/config/validators/:

...

heading0
multiplefalse
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

...

Mgnl f
form

...

Mgnl f
config

...

Mgnl f
validators

...

Mgnl n
email

...

Mgnl p
class

...

Mgnl p
expression

...

Mgnl n
number

...

Mgnl n
noHTML

...

Mgnl p
class

...

Mgnl n
password

...

Mgnl n
fileUpload

...

Mgnl n
username

...

Mgnl n
uniqueEmail

...

Mgnl n
empty

Properties:

validators

required

Validator configuration node

<validator name>

required

Name of the validator.

class

required

Validator class that performs the validation.

<validator properties>

required/optional

Available properties depend on the validator class.

  Validator configurations:

...

Value needs to be a valid email address.

Properties:

class

required

info.magnolia.module.form.validators.RegexValidator (

Javadoc
0info.magnolia.module.form.validators.RegexValidator
)

expression

required

Validity is checked with regular expression (^([a-zA-Z0-9_\.\-+])+@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$).

...

Value needs to be a number, specifically an integer. No decimals separated with period or comma or fractions are accepted.

Properties:

class

required

info.magnolia.module.form.validators.RegexValidator (

Javadoc
0info.magnolia.module.form.validators.RegexValidator
)

expression

required

Validity is checked with regular expression ^[0-9]*$.

...

Value cannot any have HTML markup. This ensures that users can only enter plain text. Creating links and formatting text is prevented.

Property:

class

required

info.magnolia.module.form.validators.NoHTMLValidator (

Javadoc
0info.magnolia.module.form.validators.NoHTMLValidator
). Custom class that checks for the presence of angle brackets (< >).

...

Validates that the password entered into two password fields match. Used to eliminate typos.

Property:

class

required

info.magnolia.module.form.validators.PasswordValidator (

Javadoc
0info.magnolia.module.form.validators.PasswordValidator
). The fields should be named password and passwordConfirmation.

...

Validates against a list of allowed mime types and a max file size.

Properties:

class

required

info.magnolia.module.form.validators.FileUploadValidator (

Javadoc
0info.magnolia.module.form.validators.FileUploadValidator
).

maxFileSize

optional, default is 10485760

Max file upload size

allowedMimeTypes

optional

Content node for list of allowed mimeTypes. Add a property for each additional type. By default, application/pdf, image/gif, image/jpeg, image/jpg and image/png are allowed.

...

No validation. Used for Honeypot field only.  

Properties:

class

required

info.magnolia.module.form.validators.RegexValidator (

Javadoc
0info.magnolia.module.form.validators.RegexValidator
).

expression

required

- (dash/null)

...

Verifies that the entered username does not exist in the system. This validator is added by the Public User Registration (PUR) module.

class

required

info.magnolia.module.publicuserregistration.validators.UsernameValidator (

Javadoc
0info.magnolia.module.publicuserregistration.validators.UsernameValidator
).

...

Verifies that the entered email does not exist in the system. This validator is added by the Public User Registration (PUR) module.

class

required

info.magnolia.module.publicuserregistration.validators.UniqueEmailValidator (

Javadoc
0info.magnolia.module.publicuserregistration.validators.UniqueEmailValidator
).

Form processors

Form processors configured in the module are responsible for sending submitted form data by email. The processors are executed when the form is submitted. The email content corresponds with the settings configured in the relevant tabs of the Form component.

Processors are configured in /modules/form/templates/components/form/formProcessors.

...

heading0
multiplefalse
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

...

Mgnl f
form

...

Mgnl f
templates

...

Mgnl f
components

...

Mgnl n
form

...

Mgnl n
formProcessors

...

Mgnl n
sendContactEmail

...

Mgnl p
class

...

Mgnl p
enabled

...

Mgnl n
sendCofirmationEmail

...

Mgnl p
class

...

Mgnl p
enabled

...

Mgnl n
trackEmail

...

Mgnl p
class

...

Mgnl p
enabled

...

Mgnl p
loggernName

...

Properties:

...

required

Form processor node.

...

<form processor name>

...

required

Name of the form processor.

...

class

...

required

  • info.magnolia.module.form.processors.SendContactEMailProcessor (
    Javadoc resource link
    classNameinfo.magnolia.module.form.processors.SendContactEMailProcessor
    renderTypeasynchronous
    ): Sends form data in email to the address specified in the To field. The processor extracts values from the From, To, Subject and Text fields and creates an email message in plain text or HTML format depending on form settings. Any uploaded files are sent as attachments.   
  • info.magnolia.module.form.processors.SendConfirmationEMailProcessor (
    Javadoc resource link
    classNameinfo.magnolia.module.form.processors.SendConfirmationEMailProcessor
    renderTypeasynchronous
    ): Sends a confirmation email. The processor first verifies if the Send confirmation checkbox is checked and sends a message to the address specified in the To field. By default, this processor is not enabled. This is the case even if the Send confirmation checkbox is checked in form settings. To enable it, add an enabled property under the processor and set the value to true.
  • info.magnolia.module.form.processors.TrackEmailProcessor (
    Javadoc resource link
    classNameinfo.magnolia.module.form.processors.TrackEmailProcessor
    renderTypeasynchronous
    ): Writes the content of the submitted form to magnolia-form.log file if the Track Mail checkbox is checked. By default, this processor is not enabled. This is the case even if the Track Mail checkbox is checked in form settings. To enable it, add an enabled property under the processor and set the value to true.

...

enabled

...

optional , default is false

Enables and disables the processor

...

loggerName

...

required

The logger name. Only relevant for trackEmail processor.

Creating a custom form processor

The three example form processors above send the form data in email, but you can write a custom form processor to do almost anything. If you need to store the data in a database or process it in another way, write your own form processor. You can also try the Form2DB App that is a community developed app that saves form data via form processor into the JCR and allows for export to XLS.

Info

Create a new form component definition for your custom processor. If you simply add the custom processor to the default component definition it will be executed for all forms.

For more examples see Form processors in the PUR module

You can also create a form processor with server-side JavaScript.

Form components

The form components are configured in /modules/form/templates/components

...

heading0
multiplefalse
enableHeadingAttributesfalse
enableSortingfalse
classm5-configuration-tree
enableHighlightingfalse

...

Mgnl f
form

...

Mgnl f
templates

...

Mgnl f
components

...

Mgnl n
form

...

Mgnl n
formFile

...

Mgnl n
formEdit

...

Mgnl n
formStep

...

Mgnl n
formHidden

...

Mgnl n
formSubmit

...

Mgnl n
formSummary

...

Mgnl n
formPassword

...

Mgnl n
formHoneypot

...

Mgnl n
formGroupEdit

...

Mgnl n
formCondition

...

Mgnl n
formSelection

...

Mgnl n
formGroupFields

Mgnl n

...

Info
  • The escapeHtml property escapes any HTML code entered in a form input field. This is a security feature that prevents XSS attacks. Default is true for all form fields.
  • Javadoc resource link
    classNameinfo.magnolia.module.form.templates.components.AbstractFormModel
    renderTypeasynchronous
    ensures that pages with forms are not cached.

...