Modifiers allow you to format incoming data to the Merge Field in the way you want. For example, you can add a modifier to capitalize the first word in each sentence of the incoming data or format a number to have a currency sign. This article will show you how to apply modifiers to your Merge Fields in our document builder and will take you through which modifiers are available to you. We also cover the old or manual way of writing these with a merge field if you're creating a document outside of our builder.
Getting Started With a Merge Field
Before adding a modifier, let’s first create a Merge Field. Click the “Insert” button from the right of the builder and choose the “Merge Field” option.
You will see a Merge Field pill placed in the builder. Click the pill to open the Merge Field settings.
There are two options to add a Modifier to your Merge Field, you can either choose from a commonly used modifier from our drop-down list or write a customized modifier. Let’s explore both options below.
Choose a modifier from the drop-down list
In the drop-down list, we have selected the most commonly used modifiers that do not need any additional configuration, like the one we selected in this example.
By applying this “Date (m/d/y)” modifier, your incoming data will appear in the form of month/day/year, regardless of how it was initially submitted. When you make a selection, you can see the modifier being added right below the drop-down.
Lastly, click the “Update Merge Field” button to save your changes. A tag icon inside the Merge Field indicates a modifier is applied.
Write a customized modifier
For this method, please refer to the bottom of this article for a list of modifiers we support.
From the dropdown, choose the “Use other” option.
This is where you can add a customized modifier that is not on the drop-down list.
For example, we can add a modifier and add 10 days to a date by using “the add_days:10” modifier. When you click the plus icon, we verify the modifier. An error message will show up if you have a typo in an input or use an unsupported modifier. If the modifier is successfully added, you can see it added right below the field.
Click the “Update Merge Field” button to save your changes. A tag icon inside the Merge Field pill on your document indicates a modifier is applied.
How many modifiers can I apply to my merge Field?
You can use as many modifiers as you need.
What is the order in which the modifiers will be applied?
The modifiers will be applied top-down. You can re-order modifiers by grabbing and dragging the dotted handles within the area.
Can I add modifiers the “old/manual way”?
Yes! If you have been using Formstack Documents for a while, you may feel more comfortable writing out the Merge Fields and modifiers directly in the builder. You can continue using the pipe ‘|’ to separate a Merge Field from the modifier {$Merge_Field|modifier}. Once you close the curly bracket ‘}’, the Merge Field text will turn into a reusable, drag-and-drop pill with a modifier attached to it. You can follow the above steps to make any additional edits.
Which are the available modifiers?
Name |
Description |
Example |
|---|---|---|
| abbreviation | Convert text to abbreviation (grab first letter of each word) |
{$Field|abbreviation:"suffix":"prefix"} |
| add_days | Add days to date |
{$Date|add_days:10} |
| age | Convert date into age (years) |
{$Birthdate|age} |
| age_to_words | Convert date into age in words |
{$Birthdate|age_to_words} = 2 years 3 days 4 hours |
| bitly | Convert URL to Bitly link |
{$Website|bitly:"username":"password"} |
| calendar | Make calendar from array of dates |
{json_encode($dates)|calendar} |
| capitalize | Capitalize the first letter of a merge field |
{$FirstName|capitalize} |
| capitalize_sentences | Capitalize the first word in each sentence |
{$Description|capitalize_sentences} |
| cat | Append text to the end of a merge field |
{$Name|cat:" is ready"} |
| csv_to_array | Convert CSV string (or URL) to an array |
{$csv = $file_url|csv_to_array} |
| currency_format | Format a currency value |
{$TotalAmount|currency_format:"$"} = $1,298.99 International Format: |
| date_format | Change the format of a date |
{$StartDate|date_format:"m/d/Y"} |
| decimal_to_words | Convert a decimal/number to words |
{$Ratio|decimal_to_words} = three and 7 tenths |
| default | Set a default value for a merge field |
{$FavoriteColor|default:"None"} |
| expand_url | Get real URL (follow redirects) from a shortened URL |
{$short_url|expand_url} |
| get_file | Download file from URL |
{$text = $url|get_file} |
| html_safe | Convert characters to HTML safe characters |
{$word|html_safe} |
| html2office | Convert HTML to Office doc formatting |
{$Description|html2office} |
| html2text | Convert HTML to plain text |
{$Description|html2text} |
| implode | Combine list of array values into single string with a separator |
{implode(", ", $Colors)} |
| int_number | Convert international number to US format (for calculations) |
{$Total = $Subtotal|int_number + $Tax|int_number} |
| list array values | List array values in a commas separated list (Forms for Salesforce) |
{$Colors|list:",":"and"} = Red, Green, and Blue |
| list string values |
List string values in a commas separated list (Forms) |
{explode("\n",$Colors)|list:",":"and"} = Red, Green, and Blue |
| lower | Convert all characters to lowercase |
{$Name|lower} |
| markdown2html | Convert markdown to html |
{$Description|markdown2html} |
| money_to_words | Convert price to words |
{$Total|money_to_words} |
| nl2 | Convert new-line characters to given string |
{$Description|nl2:", "} |
| nl2br | Convert new-line characters to HTML line breaks |
{$Description|nl2br} |
| nl2p | Convert new-line characters to HTML paragraph |
{$Description|nl2p} |
| number | Convert merge field to a number (for calculations) |
{$Total|number} |
| number_eu_to_us | Converts a number from EU format to US |
{$eu_number|number_eu_to_us} |
| number_us_to_eu | Converts a number from US format to EU |
{$us_number|number_us_to_eu} |
| number_format | Change the format of a number (commas and decimals) |
{$TotalPrice|number_format:2} International format (comma for decimal place) |
| number_to_words | Convert number to words |
{$Total|number_to_words} |
| pad | Pad merge field with the given string, so it is the given length |
{$AccountNumber|pad:12:"0"} |
| parse_url | Searches string for a URL |
{$image|parse_url} |
| phone_format | Format a phone number |
{$WorkPhone|phone_format:"(%3) %3-%4"} |
| replace | Search and replace a string in a merge field |
{$Address|replace:"Street":"St"} |
| round | Round a number to number of decimal places provided |
{$Price|round:2} |
| spacify | Insert a space (or string) in between each character in merge field |
{$Name|spacifiy} |
| state_abbreviation | Convert US State name to abbreviation |
{$State|state_abbreviation} |
| strip | Replace all new lines, spaces, and tabs with a single space |
{$Description|strip} |
| strip_tags | Remove all HTML tags from merge field |
{$Description|strip_tags} |
| substr | Create a sub-string of the merge field |
{$Description|substr:start:length} |
| text2html | Convert text to HTML |
{$Description|text2html} |
| time_to_words | Creates a text representation of the number of seconds |
{$time_in_seconds|time_to_words} |
| translate | Translate text into another language |
{$Description|translate:"de"} via Google Translate - Languages |
| truncate | Truncate/shorten the merge field to the given length |
{$Description|truncate:140} (140 characters) |
| ucfirst | Capitalize the first letter in the first word |
{$FirstName|ucfirst} |
| ucwords | Capitalize the first letter in each word |
{$Name|ucwords} |
| upper | Convert all characters to uppercase |
{$Name|upper} |
| xml_safe | Encode merge field data for XML (Office) docs |
{strftime("%d %B %Y", strtotime($_date))|ucwords|xml_safe} |
Other considerations:
- International date translation: {strftime("%d %B %Y", strtotime($_date))|ucwords}
- More formatting options for strftime: https://php.net/strftime
- Date formatting:
For more information on using variable modifiers, please visit https://www.smarty.net/docs/en/language.modifiers.tpl