Link to page
Schema:
{
"type": "object",
"properties": {
"type": {"type": "string", "pattern": "^form-field$"},
"id": {"type": "string", "pattern": "^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$"},
"machine_name": {"type": "string"},
"data": {
"type": "object",
"properties": {
"uid": {"type": "string","pattern": "^form-link$"},
"title": {"type": "string"},
"value": {
"type": "object",
"properties": {
"url": {"type": "string"}
}
}
}
}
},
"required": ["id", "type", "data"]
}
Example output:
Given "Link to page" form element on a component set up like so
And used on Node layout canvas like so (given that "Test Page, Please Ignore" is a Drupal Node with id "5")
JSON:API output for this form field will be this:
{
"type": "form-field",
"id": "7cc6c4c8-da14-4c2d-8e4d-f34187758f43",
"machine_name": "link-to-page",
"data": {
"uid": "form-link",
"title": "Link to page",
"value": {
"url": "https://sitestudiodocs.acquia.com/node/5",
"jsonapi_link": "https://sitestudiodocs.acquia.com/jsonapi/node/layout_page/050cdf6a-310f-49b8-8059-5e0e705fb961"
}
}
}
The "value" property is an object containing "url" property that is absolute link to "Test page, Please Ignore" page with Drupal node id 5. The "jsonapi_link" here is canonical Drupal route to JSON:API resource representing "Test Page, Please Ignore" node.
If same component containing "Link to page" form element is used with external URL like so:
JSON:API output for this form field will be this:
{
"type": "form-field",
"id": "618bd7fe-e48d-4407-b1b3-dfae708b9d75",
"machine_name": "link-to-page",
"data": {
"uid": "form-link",
"title": "Link to page",
"value": {
"url": "https://youtu.be/dQw4w9WgXcQ?si=ELei-LXbyEZU1Lcd"
}
}
}
The "value" property is an object containing "url" property that contains external link. As there is no internal Drupal entity to link to there is no "jsonapi_link" property.