There are many times when it is convenient to have default values or placeholders in your form fields. Formidable Forms allows for two types of default values:
- Standard Default Values: these default values will make it easier for users to complete your forms. For example, you could automatically populate a logged-in user's first name, last name, or email address.
- Placeholders: these default values will clear when a user begins typing in the field (in the case of instructions or an example). These default values are not saved with the form submission.
- Default values will be used when a new entry is created or when a field is conditionally shown.
- Default values will not replace submitted values when you edit an entry, even if the submitted value is empty.
Add a default value
If you would like to add a default value to one of your fields, select or enter the value as you are building/editing the form.
Add a default value to a text field
- Go to your form Build page.
- Select the field where you would like to insert a default value. In the Field options → Advanced → Default Value, select the text icon and insert your desired default value text into the field.
Add a default value to a Radio field
- Go to your form Build page.
- Find the Radio field that you would like to set a default value for, and select the default option. After doing so, update the form.
The form will have this option selected by default, but the user can still change the selection.
Add a default value to a Checkbox field
- Go to your form Build page.
- Find the Checkbox field that you would like to set a default value for, and select the default option(s). After doing so, update the form.
The form will have this option(s) selected by default, but the user can still change the selection.
Add a default value to a Dropdown field
If you would like to set a default value for a dropdown, select the option from the dropdown in your field settings, then save.
The form will have this option selected by default, but the user can change the selection.
Add a default value to a Dynamic field
Dynamic fields and post category fields work a bit differently for setting default values than other field types. Since the options are not listed in the settings sidebar, the Default Value option should be used. To select a default value for a dynamic field, double click on the field. Click the dots in the Default Value box to show the options. Select any of the values to set it as a default value.
Add a default value from another field
You can use a Dropdown, Checkbox, or Radio field to display values from other fields on the same form.
- Go to your form Build page and add the fields whose content you want to show.
- Add a page break in between these fields to pass it as a default value.
- On the next page, add in the Dropdown, Checkbox, or Radio field and insert the IDs of the fields from the first page.
- Display default value in a Dropdown field
- Display default value in a Checkbox field
- Display default value in a Radio field
Replace 25, 26, 27 with ID of your Dropdown, Checkbox, or Radio field.
Add a default value after form submit
If you show the form after submission, you can include the value submitted by adding the field ID as the default value. It is helpful for calculators that show a prefilled form after submission. If you have a multi-page form, you can include the value of a field from a previous page.
- Go to your form Build page.
- In the field options, insert the field ID as the default value. Using the default parameter is also supported. e.g. [25 default=something]
- Go to your form Settings → Actions & Notifications. Click on the Confirmation form action.
- Select the Show Message button and toggle the option to Show the form with the confirmation message.
- After form submission, the fields are auto-populated with the most recent value.
Add a placeholder
Form placeholders are typically instructions or text that tell the user what to enter. You may see 'First Name' in a text field, for example, and then you know to enter your first name. In a dropdown field, you may see '-Select a meal-' and then you'll know you need to select a meal. Placeholder values are not saved with the entry.
Add a placeholder to a text field
- Go to your form 'Build' page.
- Select the field where you would like to insert a placeholder. Go to the Advanced section in the left sidebar and insert your desired placeholder text into the field.
- The placeholder text will clear when a user begins typing in the field, as shown below:
Add a placeholder to a Dropdown field
- Go to your form 'Build' page.
- Select the Dropdown field where you would like to add the placeholder. Go to the Advanced section in the left sidebar and insert the value you would like to be shown as the placeholder.
- If the dropdown field is required, the user will not be able to submit the form without selecting a different option. The placeholder value will not be saved with the entry.
If your dropdown field is using autocomplete in the field settings you will see Select an option as the default placeholder.
Styling placeholder text
To change the color of the placeholder text inside a field, see the instructions in styling placeholder text.
Smart default values
Smart default values are default values that are dynamically generated. This is helpful because you can populate a field with a user's first and last name from their profile, for example. Or you may populate a field with a user's address that was submitted in a previous entry.
Insert a smart default value
Smart default values are generated by inserting a smart default value shortcode in the Default Value box in the field options.
- On the form builder page click a field to get the field options in the right sidebar.
- Open the Advanced section and click the dots in the Default Value box. This opens a section with a complete, clickable list of the available smart default value shortcodes.
- Click on any smart value to insert it into the Default Value box.
Smart default value shortcodes
The following is a list and description of all the smart default value shortcodes which you may use in your form. If you would like to set a custom smart default value, you can create your own WordPress shortcode or use the frm_get_default_value hook.
Current date
Display the current date in the format selected in your Formidable → Global Settings. Use format="Y-m-d" to display a different format. Any of the PHP date() format characters are allowed here. Usage: [date] or [date format="Y-m-d"]
Other dates
If you need a default date other then today, use the 'offset' option in the [date] shortcode. For example, to get the date 3 days from now, use [date offset='+3 days']. This option can also be used in combination with the format option. [date offset='+3 days' format='Y-m-d'].
When using offset, you may use any date string that is accepted by the PHP strtotime() function. Not sure what can be used? Take a look at a few common examples.
Time
Display the current time in the hh:mm:ss format. You may change the format with the format parameter and round the value to the nearest 30 minutes. Usage: [time] or [time format='h:i A' round=30]
Get the email address from the profile of a logged-in user. Usage: [email]
Username
Display the login/username of a logged-in user. Usage: [login]
Display name
Get the display name from the profile of a logged-in user. Usage: [display_name]
First name
Display the first name from the profile of a logged-in user. Usage: [first_name]
Last name
Get the last name from the profile of a logged-in user. Usage: [last_name]
User ID
Get the user ID (number) of a logged-in user. Usage: [user_id]
User role
Retrieve the WordPress role of a logged-in user. Usage: [user_role]
User meta
Get any information from the logged in user's profile with the [user_meta key="meta_name"] shortcode. Replace "meta_name" with the meta name of the info. Usage: [user_meta key="user_url"], [user_meta key="user_description"]
Post ID
Get the ID of the post your form resides on. Usage: [post_id]
Post title
Display the title of the post your form resides on. Usage: [post_title]
Post author email
Get the email address of the post author from the post your form resides on. Usage: [post_author_email]
Post meta
Get any information saved to custom fields in the post your form resides on. Use [post_meta key=whatever] and replace 'whatever' with the custom field name. Usage: [post_meta key="_visibility"]
IP address
Get the IP address of the user filling out the form. Please note that this shortcode returns the ipv4 address of the user, not their private/local IP. Usage: [ip]
Server values
This shortcode allows you to access PHP's $_SERVER superglobal, including page URLs. See the full list of available SERVER values.
Get the current or referring URL
Get the URL of the current page or the referring page. Use [server param="REQUEST_URI"] in a text field/hidden field to get the URL of the current page. Use [server param="HTTP_REFERER"] to get the URL of the previous page. If you are using this value in a multi-paged form, the field must be on the first page of the form in order to get the desired value.
Automatically increment an ID
Use [auto_id start=1] to insert a number that increases by one with each entry for the form. This shortcode can include a prefix and/or suffix along with it, but the prefix and/or suffix should not include numbers. The [auto_id] shortcode always returns a unique value. The final submitted value may end up being different from the value displayed on the screen when you first load the form, such as if there are multiple users filling out the form at the same time.
Usage: [auto_id start=1] or abc_[auto_id start=1]_xyz
The auto increment value is checked at two different times to make sure it's unique:
- First, the value is checked against other saved values when the form is loaded. It is possible that two people may be filling out a form with the same auto id value.
- Second, when the form is submitted, the value is checked during validation against the latest value stored in the database and updated if the value has been used. There are cases when the auto id is not unique when two people submit a form in the same millisecond. This is rare, and can be prevented by marking the auto increment field unique. This will cause one of the two users submitting at the exact same time to resubmit, updating the value correctly.
- The [auto_id] shortcode is not set-up to work inside of repeaters.
- Numbers shouldn't be used directly before or after the [auto_id] shortcode. A letter or a character like _ can be used to separate numbers from [auto_id]. So 1000[auto_id] shouldn't be used, but 1000_[auto_id] is fine.
Shortcode options
- Start: Determines the starting point for the increment. The default value is 1.
[auto_id start=2]
- Step: Determines the interval between increments. The default value is 1.
[auto_id step=2 start=2]
Get a parameter from the URL
Use [get param="param_name"] to get a parameter from the URL or from the WP Query object. To set it up, follow the instructions below.
- In your field Settings → Default Value box, insert [get param="param_name"]. Replace param_name with your preferred parameter name.
- For example, if your URL is set up like examplesite.com/form/?job=cashier, your parameter name is job and the assigned value is cashier.
- You can then insert [get param="job"] in a form field or View, which would automatically be replaced by the cashier value.
- If the parameter is blank or not included in the URL, you can set a default value with the default parameter.
[get param="job" default="Default Value"]
- When using this shortcode to filter a Formidable view, always set a default value (i.e. default="0") when filtering sensitive information/entries in order to protect entries that should not be public.
- The [get param="param_name"] and [if get] shortcode can also be used in the form settings and Customize HTML - Submit button.
Pass a value to a Form
Automatically transferring data from one form to another form is a useful feature. This method can be beneficial for displaying or saving additional information in the second form.
- Go into Form A and click on Settings → Actions & Notifications. Click the Confirmation action and select the Redirect to URL button.
- In the Redirect URL box, insert the URL of the page that contains Form B, followed by a parameter that includes the entry ID from Form A. At the end of the link, add a parameter to the link like ?param-name=[id]. Replace param_name with your preferred parameter name, but leave [id] as it is.
For example, if your URL is set up like https://examplesite.com/application/?project=[id], your parameter name is project. - Go into Form B and add a field with [get param="param-name"] inserted in the Default Value box. This will display the field value from Form A.
- That's it! After submitting an entry in Form A, users will be redirected to Form B where the entry ID from the View or Form A will be included in the URL. The field in Form B will then be automatically populated with a value from Form A.
Pass a value to a dynamic field
Suppose you want to automatically link two forms and make all the information from Form A available in Form B. In that case, you can pass information from one form to a dynamic field in another form.
- Go into Form A and click on Settings → Actions & Notifications. Click the Confirmation action and select the Redirect to URL button.
- In the Redirect URL box, insert the URL of the page that contains Form B, followed by a parameter that includes the entry ID from Form A. At the end of the link, add a parameter to the link like ?param-name=[id]. Replace param_name with your preferred parameter name, but leave [id] as it is.
For example, if your URL is set up like https://examplesite.com/application/?project=[id], your parameter name is project. - Go into Form B and add a dynamic field dropdown. Set it to the following:
- Load Options From: Form Entries
- Select a Form: Form A
- Select a Field: Project Name (this is the field you want to pass)
Insert [get param="param-name"] in the Default Value box.
- That's it! After submitting an entry in Form A, users will be redirected to Form B where the entry ID from Form A will be included in the URL. The dynamic field will then be automatically populated with a value from Form A. All the information from Form A will be accessible to any emails, posts, or Views related to Form B.
Pass a value from View to a Form
If you want to connect two forms and automatically pass data from Form A to Form B when a link is clicked in a View, you can achieve this by passing information from the View to a dynamic field in the other form.
- Navigate to the View that contains the desired information from Form A.
- In the View Listing Page Content, create a link that will redirect users to Form B. Insert the URL of the page that contains Form B, followed by a parameter that includes the entry ID from Form A. At the end of the link, add a parameter to the link like ?param-name=[id]. Replace param_name with your preferred parameter name, but leave [id] as it is.
For example, if your URL is set up like https://examplesite.com/application/?project=[id], your parameter name is project. - Go into Form B and add a dynamic field dropdown. Set it to the following:
- Load Options From: Form Entries
- Select a Form: Form A
- Select a Field: Project Name (this is the field you want to pass)
Insert [get param="param-name"] in the Default Value box.
- That's it! When a user clicks on a link within the View created from Form A, they will be redirected to Form B. In the URL of Form B, the entry ID from the View will be included. The dynamic field in Form B will be then be automatically populated with the corresponding value from the View.
Troubleshooting
If your form fields are not being auto-populated with the parameter values you have added in your URL, this is usually related to page caching. Page caching applies to visitors who are not logged in. It is designed to save the page once, and then serve it to everyone who sees the page who is logged out. To resolve this, make sure that you have page caching turned off.
Field value
Use [frm-field-value field_id=x user_id=current] to get a value previously submitted in a field by the current user. Replace x with the ID of the field you would like to retrieve the value from. For more information about this shortcode, please see the frm-field-value page.
Related developer hook
- Set the default value of any field when your form is displayed with the frm_get_default_value hook.