Version:

Acquia Cohesion renames to Site Studio from version 6.2. Tell me more.

    Entity reference

    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-entity-reference$"},
            "title": {"type": "string"},
            "value": {
              "type": "object",
              "properties": {
                "entity_type": {"type": "string"},
                "view_mode": {"type": "string"},
                "entity": {"type": "string"}
              }
            }
          }
        }
      },
      "required": ["id", "type", "data"]
    }
    

    Example output:

    Given "Entity reference" form element on a component set up like so

    And used on Node layout canvas like so

    JSON:API output for this form field will be this:

    
     
    {
      "type": "form-field",
      "id": "954f324a-d706-4f72-9cfa-e74d02aa692f",
      "machine_name": "entity-reference",
      "data": {
        "uid": "form-entity-reference",
        "title": "Entity reference",
        "value": {
          "entity_type": "node",
          "view_mode": "full",
          "entity": "6549c652-a789-410a-aeb5-534b8458a45b",
          "jsonapi_link": "https://sitestudiodocs.acquia.com/jsonapi/node/layout_page/6549c652-a789-410a-aeb5-534b8458a45b"    }
      }
    }

    In this example "value" property contains "jsonapi_link" property as the "Entity reference" form field stores a reference to a Node. The value of "jsonapi_link" property is an absolute url pointing to a JSON:API Resource for referenced node "Example node".

    DX8 knowledge base icon

    Frequently asked questions

    Get instant answers to common questions. Available online 24/7.

    Find answers

    Raise a ticket icon

    Raise a support ticket

    To raise a ticket, sign into Acquia Cloud and select Help in the top menu.

    Raise support ticket

    Acquia

    Copyright © 2020 Acquia, Inc. All Rights Reserved. Drupal is a registered trademark of Dries Buytaert.