Tag parsers - smbc-digital/form-builder GitHub Wiki
Related
NOTE: The displayed value MUST be required and cannot be optional
NOTE: Currently will work with string, DateTime Formatters
Tag parsers
Tag parsers allow us to show a collected form data value on a page. This allows us to display the users firstname
and lastname
if collected on a previous page or show some other form data which has been collected.
TagParser Methods
Parse
Currently works with Text
property for all TagParsers
and
Text
property and Hint
property for {{QUESTION:answer}} and {{FORMDATA:answer}}
and
Text
property and LeadingParagraph
for {{PAYMENTAMOUNT}} and {{CASEREFERENCE}}
ParseString
Works for any String
value
The tag is broken down into two sections, the first part is the Tag type, the seconds is the related id.
{{QUESTION:FirstName}}
so the example above is using the QUESTION
tag parser and will be replaced with the answer value from the question with id FirstName
Formatters
You have the ability to specify a formatter for the value which is to be displayed, this can be done by suppplying an additional value when adding a tag parser, refer to the Formatters entry
Current Tag parsers
Tag | Example |
---|---|
Question | {{QUESTION:FirstName}} |
Form data | {{FORMDATA:caseReference}} |
Link | {{LINK:www.stockport.gov.uk:Visit}} |
PaymentAmount | {{PAYMENTAMOUNT}} |
CaseReference | {{CASEREFERENCE}} |
MailTo | {{MAILTO:[email protected]}} |
Question
Question allow you to display any answer to a question which has been asked within the form
{
"Type": "p",
"Properties": {
"Text": "thank you {{QUESTION:firstName}} {{QUESTION:lastname}} for your application"
}
},
Formdata
FormData allows you to display a collected value which has not come directly from a question within the form, This could have come from IncomingValues
or RetrieveExternalData
{
"Type": "p",
"Properties": {
"Text": "your case reference is: {{FORMDATA:caseReference}}"
}
},
Link
NOTE: the url provided must be in www.stockport.gov.uk, do not include the https:// this is added for you
Link allows you to display a link within a line or text with the correct html properties for target _blank
and noreferrer
.
The first part is the url for the link. The second part is the text used
{
"Type": "p",
"Properties": {
"Text": "Visit our {{LINK:www.stockport.gov.uk:homepage}} for more information"
}
}
PaymentAmount
Allows you to display the total payment amount on a page
NOTE: this can ONLY be used on forms that require a payment and there must be a payment-configuration set up
NOTE: this cannot be used on the first page of a form
NOTE: if the form has items of different prices/quantities, this can ONLY be used on pages after the user has selected what they are paying for eg. after choosing a type of bin or a quantity of copy certificates
{
"Type": "p",
"Properties": {
"Text": "The total amount you need to pay is £{{PAYMENTAMOUNT}}."
}
},
CaseReference
Allows you to display the Case Reference on a post-submission page
NOTE: this can ONLY be used on pages that occur after successful submissions
{
"Type": "p",
"Properties": {
"Text": "Your case reference is {{CASEREFERENCE}}"
}
},
Question with Formatter
Displayed the question dateValue
with the full-date formatter
{
"Type": "p",
"Properties": {
"Text": "your case reference is: {{QUESTION:dateValue:full-date}}"
}
},
MailTo
NOTE: the email provided must include an @ sign. It does not validate the email in anyway.
MailTo allows you to display a mailto within a line or text with the correct html properties for target _blank
and noreferrer
.
{
"Type": "p",
"Properties": {
"Text": "Contact {{MAILTO:[email protected]}} for more information"
}
}