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 EXCEPT OLIST and ULIST

and

Text property and Hint property for {{QUESTION:answer}} and {{FORMDATA:answer}} and {{STRONG::text}} and {{BOLD::text}} and {{EMPHASIS::text}} and {{ITALIC::text}} and {{BREAK}} and {{IMAGE::url::alt text}}

and

Text property and LeadingParagraph for {{PAYMENTAMOUNT}} and {{CASEREFERENCE}}

and

IAG property and Hint property for {{ULIST::item 1|item 2}} and {{OLIST::item 1|item 2}}

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

NOTE - Strong, Bold, Emphasis, Italic, Image, Unordered list and Ordered list require double ::

Tag Example
Question {{QUESTION:FirstName}}
Form data {{FORMDATA:caseReference}}
Link {{LINK:www.stockport.gov.uk:Visit}}
PaymentAmount {{PAYMENTAMOUNT}}
CaseReference {{CASEREFERENCE}}
MailTo {{MAILTO:[email protected]}}
Strong {{STRONG::text}}
Bold {{BOLD::text}}
Emphasis {{EMPHASIS::text}}
Italic {{ITALIC::text}}
Break {{BREAK}}
Image {{IMAGE::src url::alt text}}
Ordered list {{OLIST::item 1|item 2}}
Unordered list {{ULIST::item 1|item2}}
Date {{DATE::string}}

Question

Question allow you to display any answer to a question which has been asked within the form.

This can be utilised in the LeadingParagraph property of success pages.

{
    "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"
    }
}

Date

Allows you to pull through a dynamic date, either based on a predefined string listed below:

Parameter Output
childBirthYear Current date - 15 years
adultBirthYear Current date - 40 years
oapBirthYear Current date - 66 years
nextWeek Current date + 7 days
nextMonth Current date + 1 month
nextYear Current date + 1 year
lastWeek Current date - 1 week
lastMonth Current date - 1 month
lastYear Current date - 1 year
{
    "Type": "p",
    "Properties": {
        "Text": "the date is {{DATE::childBirthYear}}"
    }
},

Or a custom day, week, month or year parameter that's passed in the format:

(+/-)(X)(d/w/m/y)

The example listed below would return current date + 17 years.

{
    "Type": "p",
    "Properties": {
        "Text": "the date is {{DATE::+17y}}"
    }
},