Fields
Freeform features its own set of robust field types. The form builder displays a list of available field types which can then be added to forms indefinitely. Fields are specific to each form, but can also be saved as favorites or searched upon to be reused in other forms.
Overview
Standard Settings
There is a standard number of settings available to all forms (with some exceptions). Every form field has the ability for you to do the following:
Setting | Template Usage | Description |
---|---|---|
Label | label | The label for the field. This can be changed per form if you wish. |
Handle | handle | How the field may be called in templates, if necessary. You may also override this value per form if you wish. |
Required | required | Toggle if the field requires a value to submit the form successfully. |
Custom Validation ErrorNew in 5.7+ | Visible when Required is toggled on. If this field is left empty upon submit, show this error message. | |
Instructions | instructions | Specify intructions for the field if you wish. |
Default Value | defaultValue | For applicable fields, you can set a default value or selected option for the field. |
Placeholder | placeholder | Specify placeholder text for the field, if applicable. |
Maximum Length | maxlength | The maximum number of characters for the field's value. |
Attribute Editor | Apply any kind of attribute on the input, label, error, instruction in Freeform's automated rendering of the form. | |
Options | options
| Specify the option labels and values for applicable field types. Applicable to the following Field types |
All field types conveniently include the ability to set attributes for their labels, inputs, errors and instructions directly inside the form builder property editor.
- This allows you to keep your hands clean of being inside formatting templates and specify one-off exceptions for fields such as
readonly
andautocomplete="off"
, etc. - To use single attributes like
novalidate
, just enter the attribute in the Attribute column and leave the Value column empty. - You can use anything inside the Form and Field objects as well, e.g.:
field.id
to access Field ID.form.handle
to access form handle.
Field EncryptionProNew in 5.0+
Each field includes the ability to optionally encrypt its submission data. Simply toggle the Encrypt field data setting inside the form builder for any field you wish to have encrypted. Freeform will take care of the rest.
For each field that is encrypted and contains submission data, the database row column will contain a prefix of encrypted:
and then the encryption string. Freeform will decrypt the submission data for exports, email notifications, integrations, and viewing submission data inside the control panel and front end (if you have templates set up to show it).
Field encryption uses the Craft Security Key (usually CRAFT_SECURITY_KEY
in your .env
file), so be sure to use the same key across multiple environments.
CRAFT_SECURITY_KEY=zVtC4j25ADUxf5H14xiIAzqKoCJtyLu7
If you wish to use a different security key for Freeform specifically, you can specify a custom key in the Secret Key setting under the Form Sessions area of the Form Behavior settings page (CP -> Freeform -> Settings -> Form Behavior).
Encryption is not retroactive. Each submission will need to be resaved to update older submissions.
Populating Field OptionsLiteProImproved in 5.0+
All multi-option field types (such as Dropdown, Checkboxes, etc) can have their option labels and values automatically populated with Craft Elements or Pre-defined list options. This allows you to quickly build forms by having fields auto-generated.
Applicable Field Types
The following field types can be auto-populated:
- Dropdown
- Optional Empty Option Label to have first option be something like
Please select...
- Optional Empty Option Label to have first option be something like
- Multiple Select
- Checkboxes
- Radios
Available OptionsLitePro
The following Freeform Predefined Options and Craft Elements can be fed to the above field types:
- Dates
- Ranges
- Regions
- Languages
- Craft Elements
Months
- All 12 months of the year.
- Option Label and Option Value choices:
- Full, e.g.
September
- Abbreviated (Capitalized 3 letters), e.g.
Sep
- Single Number, e.g.
9
- 2-digit Number, e.g.
09
- Full, e.g.
Days
- List of days
1
to31
. - Option Label and Option Value choices:
- Single Number, e.g.
3
- 2-digit Number, e.g.
03
- Single Number, e.g.
Days of Week
- List of all days of week.
- Option Label and Option Value choices:
- Full, e.g.
Thursday
- Abbreviated (Capitalized 3 letters), e.g.
Thu
- Single Number, e.g.
4
- Full, e.g.
Numbers (range)
- A custom range of numbers
- Range Start and Range End
- E.g.
60
-65
would return list:60, 61, 62, 63, 64, 65
- E.g.
Years (range)
- A custom range of years
- Range Start - number of years in PAST from current year
- Range End - number of years in FUTURE from current year
- E.g.
5
(start) -0
(end) would return list:2018, 2017, 2016, 2015, 2014, 2013
- E.g.
- Sort Direction:
- Ascending
- Descending
States
- Official USA states
- Option Label and Option Value choices:
- Full
- Abbreviated (upper case 2 letters)
States & Territories
- Official USA states and territories
- Option Label and Option Value choices:
- Full
- Abbreviated (upper case 2 letters)
Canadian Provinces
- Official Canadian provinces and territories
- Provinces - English
- Canadian Provinces and territories in English
- Provinces - French
- Canadian Provinces and territories in French
- Provinces - Bilingual
- Bilingual list of Canadian Provinces and territories
- Option Label and Option Value choices:
- Full
- Abbreviated (upper case 2 letters)
Countries
- All world countries
- Option Label and Option Value choices:
- Full
- Abbreviated (upper case 2 letters)
World Languages
- All world languages
- Option Label and Option Value choices:
- Full
- Abbreviated (lower case 2 letters)
Craft Entries
- Target sections or all sections.
- Option Label and Option Value choices:
- ID, Title, Slug, URI, Fields (simple values)
Craft Users
- Target user groups or all groups.
- Option Label and Option Value choices:
- ID, Username, Email, First Name, Last Name, Full Name, Fields (simple values)
Craft Categories
- Target category groups or all groups.
- Option Label and Option Value choices:
- ID, Title, Slug, URI, Fields (simple values)
Craft Tags
- Target tag groups or all groups.
- Option Label and Option Value choices:
- ID, Title, Slug, URI, Fields (simple values)
Craft Assets
- Target asset groups or all groups.
- Option Label and Option Value choices:
- Filename, ID, Fields (simple values)
Craft Commerce Products
- Target product type or all product types.
- Option Label and Option Value choices:
- ID, Title, Slug, URI, SKU, Price, Fields (simple values)
Convert to Custom OptionsNew in 5.0+
Sometimes you need a little more control over the populated data generated by the Element or Predefined options. You can click the Convert to Custom Options button at any time to have the generated option data converted to Custom options that can then have its options edited, removed, added, renamed, and reordered.
There are potentially negative implications with using this feature:
- Your options data can become out of sync when new elements (e.g. Entries) are added after the fact.
- If you apply this when there are already existing submissions, renaming option values will orphan submissions relying on the old value name.
- Be very careful if you attempt to redo this process (e.g. changing back to Element source and grabbing a fresh list of Craft Entries, then converting back to Custom). If any existing submissions are relying on old or modified option values, they can become orphaned in the process.
Field Types
Freeform contains a rich set of field types to handle just about every possible scenario you might get yourself into.
Fields can be changed to other field types at any point, but be aware that data loss could occur when switching incompatible field types.
Name | field.type | Description | Express | Lite | Pro |
---|---|---|---|---|---|
CalculationNew in 5.1+ | calculation | Perform dynamic calculations based on user-input values within forms. | ✕ | ✕ | ✓ |
Checkbox | checkbox | A single checkbox field. | ✓ | ✓ | ✓ |
Checkboxes | checkboxes | A group of checkboxes. | ✓ | ✓ | ✓ |
Confirm | confirm | A text input field that targets another similar field and ensures the values match. | ✕ | ✕ | ✓ |
Date & Time | datetime | A complex date and/or time field. | ✕ | ✕ | ✓ |
Dropdown | dropdown | A select dropdown menu field. | ✓ | ✓ | ✓ |
email | A text input field that includes additional email validation and possibility for attaching an email notification to it. | ✓ | ✓ | ✓ | |
File Upload | file | A regular file upload field. | ✓ | ✓ | ✓ |
File Upload Drag & Drop | file-dnd | An advanced javascript-based file uploading field. | ✕ | ✕ | ✓ |
GroupNew in 5.0+ | group | A field that contains other fields within it. | ✕ | ✕ | ✓ |
Hidden | N/A | A hidden input field. | ✓ | ✓ | ✓ |
HTML | html | A block that allows you to insert HTML into areas of your form. | ✓ | ✓ | ✓ |
Invisible | N/A | A field that allows you to collect hidden data in form submissions without a hidden field being present in the template source code. | ✕ | ✕ | ✓ |
Multiple Select | multiple-select | A multiple-select field. | ✓ | ✓ | ✓ |
Number | number | A number type input field that is validated to contain certain numbers only. | ✓ | ✓ | ✓ |
Opinion Scale | opinion-scale | A special field that allows for flexible opinion scoring. | ✕ | ✕ | ✓ |
Password | password | A text input field that collects sensitive passwords but does not store them. | ✕ | ✕ | ✓ |
Phone | phone | A tel type input field that is validated to contain phone numbers only, based on a configured pattern. | ✕ | ✕ | ✓ |
Radios | radios | A group of radio options. | ✓ | ✓ | ✓ |
Rating | rating | A special field that allows for star ratings. | ✕ | ✕ | ✓ |
Regex | regex | An input field that is validated based on the specified regex pattern (e.g. /^[a-zA-Z0-9]*$/ ). | ✕ | ✕ | ✓ |
Rich Text | rich-text | A block that allows you to insert rich text into areas of your form (headings, descriptions, etc). | ✕ | ✕ | ✓ |
Signature | signature | A field that allows users to handwrite signatures inside your form. | ✕ | ✕ | ✓ |
Stripe PaymentImproved in 5.0+ | stripe | A set of input fields to allow the validation of credit cards and other payment options for Stripe Payment implementations. | ✕ | ✕ | ✓ |
Submit buttons | N/A | Handles the submit button(s), including Save option for the form. | ✓ | ✓ | ✓ |
TableImproved in 5.8+ | table | A field that allows you to collect and handle repeating data. | ✕ | ✕ | ✓ |
Text | text | A single-line text input field. | ✓ | ✓ | ✓ |
Textarea | textarea | A multi-line text input field. | ✓ | ✓ | ✓ |
Website | website | A url type input field that checks to see if the URL specified has valid syntax. | ✕ | ✕ | ✓ |
Favorite Fields
Any field can be a favorite field! If you have a number of fields that are commonly used across more than one form, such as Name, Email, etc, you can easily save them to your Favorite Fields list. If you need to edit or remove that field, you can always do that later in the manager area.
- Favorite fields are a snapshot of that field at the time it was saved.
- Any customizations of a Favorite field or using a field from another form are specific only to the form they're adjusted in.
CalculationProNew in 5.1+
The Calculation field allows you to perform dynamic calculations based on user-input values within your forms.
For the Calculation field to work as a dynamic amount with the Stripe Payments integration, the Input Type setting should be set to Regular Text Input or Plain Text. If set to Hidden, the Calculation field should be within a multipage setup where it is on a page before the page with the Stripe Payment Element field.
Checkbox
A single checkbox field. The field.type
property value is checkbox
(for conditionals).
CheckboxesRenamed in 5.0+
A group of checkboxes. The field.type
property value is checkboxes
(for conditionals).
ConfirmProImproved in 5.0+
A field that allows you to force a user to re-enter a matching value for another text input field, including Password fields (e.g. "Confirm Email Address", "Confirm Password"). It runs through additional validation to make sure field values match. If not, it'll show an error. This field stores the data as well, in case that is important for your site's needs. The field.type
property value is confirm
(for conditionals).
Date & TimePro
A complex date and/or time field. Can be used as Date only, Time only, or both. Many configuration and validation options available as well. The field.type
property value is datetime
(for conditionals).
View Important Notes...
For localization reference:
- The Flatpickr date picker will automatically localize according to the locale set for your site. Locales available are only 2-letter codes like
fr
,de
, etc. In the event you're using a locale likefr-CA
ores-US
, etc, Freeform will just look at the first 2 letters and use that as the locale. - To translate the formatting syntax error message, be sure to translate the following strings:
"{value}" does not conform to "{format}" format.
- To translate the
{format}
rendered value to match the current locale, be sure to also translate whatever the rendered string is in the error message. For example, if you're usingfr
locale, and wish to have the default EnglishDD/MM/YYYY
show up asJJ/MM/AAAA
, create a static translation for this manually.
To customize the date picker appearance and behavior, please see Date Picker Events documentation.
DropdownRenamed in 5.0+
A select dropdown menu field. The field.type
property value is dropdown
(for conditionals).
EmailRevised in 5.0+
A single-line text input field that includes additional validation to expect a valid email address as well as the possibility of attaching an email notification to it. Pair this with the Confirm special field type if you wish to have the user enter their email address twice. The field.type
property value is email
(for conditionals).
It is required to use the Email field type if you wish for your users to receive an email notification when submitting the form and/or you're using an Email Marketing API integration.
File Upload
A regular file upload field, using Craft Assets. The field.type
property value is file
(for conditionals).
View Important Notes...
- In multi-page forms, if an earlier page contains file upload field(s), files will actually be uploaded before the form is officially submitted.
- If the form is never completed, incomplete submissions are stored for 3hrs, and then are removed (along with the files) after that.
- If you're handling sensitive files, you may wish to choose an Asset volume without public URL's (Assets in this volume have public URLs toggle is off).
File Upload Drag & DropPro
An advanced premium javascript-based file uploading field, using Craft Assets. The field.type
property value is file-dnd
(for conditionals).
View Important Notes...
- Unlike the regular File Upload field, the File Upload Drag & Drop field will remember files that have been uploaded to it regardless of the context: errors upon submission, multi-page forms, returning to edit the submission later.
- If the form is never completed, incomplete submissions are stored for 3hrs, and then are removed (along with the files) after that.
- While files are uploading, Freeform will disable the Submit button so that the form has time to finish uploading the files. If the form is submitted while files are still uploading, any that are incomplete will not be saved.
- If you're handling sensitive files, you may wish to choose an Asset volume without public URL's (Assets in this volume have public URLs toggle is off). However, please note that image file thumbnails will only be present directly after initial upload. Afterward (error when submitting, multi-page forms, returning to edit) the image thumbnails will no longer be accessible to Freeform.
GroupProNew in 5.0+
A field that contains other fields within it. To use, add a Group field into your form's layout, then add/drag other fields into that Group inside the form builder. This becomes especially powerful when using with Conditional Rules, as you'll be able create a single rule to show/hide an entire group of fields at once.
Hidden
A hidden input field.
Freeform will load fields of this type at the beginning of the form, regardless of where they are placed in the form builder layout.
To access hidden fields in GraphQL queries you have to loop through the form > fields
as they are not added to form > pages > rows > fields
.
HTML
A special field type that allows you include HTML and Twig inside your form layout in the form builder. The field.type
property value is html
(for conditionals).
View Important Notes...
- The Property Editor will load an HTML area for you to type or paste your code into.
- The Layout column in the form builder will live parse your HTML (Twig will not be parse inside the form builder).
- All HTML is allowed here.
- To enable Twig inside this field, turn on the Allow Twig to be Enabled for each HTML block? setting (and decide if you need to enable to the Render HTML block Twig in isolated mode? setting as well). Then, you will see an Allow Twig checkbox in the property editor column. Check that to allow this HTML block to parse Twig code.
Display Submission Data from Previous Pages
If you'd like to display submission data from previous pages, you can do this by using an HTML block field with Twig code that might look something like this:
<ul>
<li>Name: {{ form.get('firstName').value }} {{ form.get('lastName').value }}</li>
<li>Email: {{ form.get('email').valueAsString }}</li>
<li>Home Phone: {{ form.get('homePhone').value }}</li>
<li>My Radio Field: {{ form.get('myRadioField').value }}</li>
</ul>
InvisiblePro
A field that allows you to collect hidden data in form submissions without a hidden field being present in the template source code.
Multiple Select
A multiple-select field. The field.type
property value is multiple-select
(for conditionals).
Number
A single-line number
type input field that is validated to contain certain numbers only. The field.type
property value is number
(for conditionals).
Opinion ScaleProRevised in 5.0+
A special field that allows for flexible opinion scoring using Freeform's built in CSS. The field.type
property value is opinion-scale
(for conditionals). This field type is included automatically with the Pro edition of Freeform.
PasswordPro
A special field type that allows you to securely collect a password from a submitter but NOT store the value in the Freeform database (typically used for User Registration forms with the Elements integration). Pair this with the Confirm special field type if you wish to have the user enter their password twice. The field.type
property value is password
(for conditionals).
View Important Notes...
- Collected data is not stored in Freeform anywhere, nor is it included in the Submission object or
allFields
variable in email notifications. - When using with the Users Element integration, the password will be passed off to Craft's Users member account feature.
PhonePro
A tel
type input field that is validated to contain phone numbers only, based on a configured pattern. The field.type
property value is phone
(for conditionals).
RadiosRenamed in 5.0+
A group of radio options. The field.type
property value is radios
(for conditionals).
User Guides
- Need to display basic HTML (
<b>
,<i>
,<a>
, etc) in your option labels to add emphasis or display a link? - Need to populate field options at template level? Check out the guide for workaround options.
- Looking to include an additional "Other" choice that displays an input field for users to fill in their own value?
RatingPro
A special field that allows for star ratings using Freeform's built-in CSS. The field.type
property value is rating
(for conditionals).
This field type is included automatically with the Pro edition of Freeform.
RegexPro
An input field that is validated based on the specified regex pattern (e.g. /^[a-zA-Z0-9]*$/
). The field.type
property value is regex
(for conditionals).
Rich TextPro
A special field type that allows you include rich text inside your form layout in the form builder. The field.type
property value is rich-text
(for conditionals).
View Important Notes...
- The Property Editor will load a Rich Text area for you to type into and style as necessary.
- The Layout column in the form builder will live parse your content.
SignaturePro
A field that allows users to handwrite signatures with their mouse inside your form. The field.type
property value is signature
(for conditionals).
View Important Notes...
- Signatures are stored as an image datapoint value.
- Signatures can be downloaded as JPG or PNG files (from control panel).
- Signatures are excluded from regular exports and the
allFields
loop in email notification templates (since it would just hold an image datapoint value string). - Signatures can be edited when the form is in edit mode.
- The Clear button can be styled inside the form builder with Input attributes area inside the property editor.
- The Signature field, due to it's complexness, cannot easily be manually generated in a form, and is best done with render helpers, e.g.
field.render
. - There's currently no way to make the signature pad area "responsive" (like setting it to 100% width), as this would be quite difficult to account for with the need to display the signature image in various places, etc.
Submit buttonsRevised in 5.0+
Submit buttons are handled automatically by Freeform. They are automatically inserted at the end of your form in the form builder. This includes the Submit/Continue, Previous (where applicable), and Save & Continue Later buttons (where available).
Save & Continue LaterPro
This feature allows users to save their form progress and continue/complete the form later. For more information about this feature, please see the Save & Continue Later documentation.
Stripe PaymentProImproved in 5.0+
When the Stripe Payments integration is configured, a Stripe Payments special field type will become available. This field enables your forms to collect (but not store) credit card or other payment information and pass it off to Stripe.
TableProImproved in 5.8+
A field that allows you to collect and handle repeating data. The field.type
property value is table
(for conditionals).
Text
A single-line text input field. The field.type
property value is text
(for conditionals).
Textarea
A multi-line text input field. The field.type
property value is textarea
(for conditionals).
WebsitePro
A url
type input field that checks to see if the URL specified has valid syntax (http://
, https://
, ftp://
, etc). The field.type
property value is website
(for conditionals).