About Liquid Content™ Content Type Fields for POST and PUT APIs
The JSON structure in the body of the POST request requires a fields
array, and each field in the content type is defined as a node in the fields array.
fields
array:
"fields": [
...
{
"type": "singleLineText",
"defaultValue": null,
"setDefaultValueAsHidden": false,
"settings": {
"subType": "singleLine",
"phoneNumberFormat": null
},
"validation": {
"requireField": {
"active": true,
"errorMessage": "This is a required field"
},
"numberOfCharacters": {
"active": false,
"rangeDefinition": "between",
"minimum": null,
"minimumUnit": null,
"maximum": null,
"maximumUnit": null,
"errorMessage": "This field does not meet the required number of characters"
},
"standardErrorMessage": null
},
"id": "aa50984e-b459-4caa-94b9-5fa3a95ff082",
"name": "lastName",
"label": "Last Name",
"descriptionActive": false,
"description": "",
"tooltipActive": false,
"tooltip": "",
"row": 0,
"width": "half",
"position": "half"
},
...
]
- create one of the content types in the UI,
- request (GET) that content type from your app,
- clean up the resulting JSON to remove the specific values, such as the id of the content type and of reference fields, and
- replace the old values with values for the new type.
Field Types
A field can be any of the following types:
- Single-Line Text
- Multi-Line Text
- Number
- Multiple Choice
- Date/Time
- Assets
- Reference Object
- Static Text
Each type could require additional settings. Example: The Single Line Text type requires the subtype setting.
Also see the Validation section.
Field Type | Code Snippet(s) |
---|---|
Single-Line Text |
For a plain text field:
For a URL/website:
For an email address:
For a phone number:
|
Multi-Line Text |
For plain text:
For rich text:
|
Number |
Example:
To specify the number set:
To indicate how the selection is displayed in the UI:
To specify the number range, use floats regardless of the number set:
|
Multiple Choice |
Example:
To change how the choices are displayed in the Evoq UI:
To specify the options, enter each as the value of a label setting in the choices array.
To indicate the number of selected choices:
To specify how checkboxes and radio buttons are displayed (List orientation is ignored for dropdown lists.):
To allow Other as an option: |
Date / Time |
Example:
To choose the variation:
Valid date formats:
Valid time formats:
To use the default timezone:
To specify UTC for the indicated time:
To specify the Pacific timezone for the indicated time:
|
Assets |
For an image asset:
For a document asset:
|
Reference Object |
To accept only one reference:
To accept multiple references:
|
Static Text |
To specify a static heading (headingType can be "h2", "", ):
To specify a paragraph:
|
Name and Label
All fields require a name and a label. Example:
"name": "firstName",
"label": "First Name"
Default Value
A field could have a default value setting (defaultValue) which is stored as a string. This setting is required whether the field has a default value or not.
You can also hide the default value from the user. However, if the default value is hidden, the field must not be required.
"defaultValue" : null
With a default value that is shown:
"defaultValue" : "This is my default.",
"setDefaultValueAsHidden" : false
With a default value that is hidden:
"defaultValue" : "This is my default.",
"setDefaultValueAsHidden": true,
...
"validation" : {
"requireField" : {
"active" : false,
"errorMessage" : null
},
},
...
Validation
You can optionally require validation for data entered in the field. Each field type requires different validation settings.
Example: The following settings require a value for a Single-Line Text field but it doesn't impose a limit on the number of characters that can be entered:
"validation": {
"requireField": {
"active": true,
"errorMessage": "This is a required field"
},
"numberOfCharacters": {
"active": false,
"rangeDefinition": "between",
"minimum": null,
"minimumUnit": null,
"maximum": null,
"maximumUnit": null,
"errorMessage": "This field does not meet the required number of characters"
},
"standardErrorMessage": null
}
The validation node can contain the following settings.
Validation Setting | Applicable in Field Types | Description and Example |
---|---|---|
requireField | All field types |
If the field is optional,
If the user must enter a value for the field,
|
standardErrorMessage | All field types |
The error message to use for all other errors without defined error messages.
|
numberOfCharacters | singleLineText |
If the field can contain any number of characters,
If the number of characters must be restricted, you can specify a range, only the minimum, or only the maximum. Range restriction: If the text must have 5 to 140 characters,
Minimum restriction: If the text must have at least 20 characters,
Maximum restriction: If the text must have no more than 500 characters,
|
numberOfReferences | referenceObject (Multi-Reference Object) |
If the field can contain any number of references,
If the number of references must be restricted, you can specify a range, only the minimum, or only the maximum. Range restriction: If the field must refer to 2 to 5 content items,
Minimum restriction: If the field must refer to at least 2 content items,
Maximum restriction: If the field must refer to no more than 5 content items,
|
dropdownOrder | numberSelector |
|
dateRange | dateTime |
If the date is not restricted,
If the date must be restricted, you can specify a date range ( Range restriction: If the date must fall between 2017-07-10 and 2017-07-14,
"dateRange": {
"active": true,
"rangeDefinition": "between",
"startDateTime": "2017-07-10T19:00:00Z",
"endDateTime": "2017-07-14T19:00:00Z",
"errorMessage": "Your date is not within the accepted date range."
}
Start date restriction: If the date must be after 2017-07-31,
"dateRange": {
"active": true,
"rangeDefinition": "after",
"startDateTime": "2017-07-31T19:00:00Z",
"endDateTime": null,
"errorMessage": "Your date is not within the accepted date range."
}
End date restriction: If the date must be before 2017-07-01,
"dateRange": {
"active": true,
"rangeDefinition": "before",
"startDateTime": null,
"endDateTime": "2017-07-01T19:00:00Z",
"errorMessage": "Your date is not within the accepted date range."
}
|
timeRange | dateTime |
If the time is not restricted,
If the time must be restricted, you can specify a time span ( Span restriction: If the time must fall within a time span,
"timeRange": {
"active": true,
"rangeDefinition": "between",
"startDateTime": "09:00:00",
"endDateTime": "19:59:00",
"errorMessage": "Your time is not within the accepted time range."
}
Start time restriction: If the time must be after 21:00,
"timeRange": {
"active": true,
"rangeDefinition": "after",
"startDateTime": "21:00:00",
"endDateTime": "23:59:00",
"errorMessage": "Your time is not within the accepted time range."
}
End time restriction: If the time must be before 05:00,
"timeRange": {
"active": true,
"rangeDefinition": "before",
"startDateTime": "00:00:00",
"endDateTime": "05:00:00",
"errorMessage": "Your time is not within the accepted time range."
},
|
User Hints
To provide hints that describe the purpose of the field, you can add a field description or a tooltip.
Setting | Description and Example |
---|---|
Description
|
Set descriptionActive to true to display the value of description below the field in the Evoq UI.
No description:
With description:
|
Tooltip
|
Set tooltipActive to true to include the information icon, which displays the value of tooltip when clicked/tapped in the Evoq UI.
No tooltip:
With tooltip:
|
UI Positioning
Some settings are required to display the content type correctly in the UI. The canvas that displays the fields are comprised of rows. Each row can be divided into three or four equal parts, and each part contains one field.
Setting | Description and Example |
---|---|
row | The numbering of rows are zero-based; therefore, the first row is Row 0.
Example: |
width | The width of the field, relative to the width of the canvas. Possible values are:
Note: The division of the row must be consistent between width and position.
Examples:
|
position | The position of the field in the row.
If the row is divided into four sections, possible values are:
If the row is divided into three sections, possible values are:
Note: The division of the row must be consistent between width and position.
Examples:
|
If width is full
, the position must be start
, and no other fields are allowed in the same row.
"row" : 0,
"width" : "full",
"position" : "start"