Validations field (Allow links and inline records for these models)

Please explain to me what these field validation settings mean? When I try to use this field on the page, nothing is inserted on the front of the site.
Edit Field → Validations → Checkbox Allow links and inline records for these models

Hi @greeb.spb,

Some of our fields allow linking to blocks and other record, which you can use to define inter-model relationships.

In this case, it looks like you’re in our Next.js blog starter example, editing a Structured Text Field: Structured text fields — DatoCMS

That validation allows you to link to other defined records, in this case, another blog post. As you see, that allows you to link to other posts within a post’s content.

HOWEVER, that by itself only edits the content. It doesn’t automatically change the frontend because you have to do a couple more things first:

Step One: Add the query

You need to add the new link to your GraphQL query. In the playground, it looks like this:

Query:

{
  post(filter: {id: {eq: "19072916"}}) {
    id
    title
    _status
    _firstPublishedAt
    content {
      links {
        __typename
        id
        title
        slug
      }
    }
  }
}

Response:

{
  "data": {
    "post": {
      "id": "19072916",
      "title": "Unforgettable Trip to The Great Wall in China (draft)",
      "_status": "published",
      "_firstPublishedAt": "2020-03-10T13:49:10+00:00",
      "content": {
        "links": [
          {
            "__typename": "PostRecord",
            "id": "19072917",
            "title": "Mistakes Tourists Make on Their First Trip Abroad",
            "slug": "mistakes-tourists-make-on-their-first-trip-abroad"
          }
        ]
      }
    }
  }
}

Similarly, in the starter project, you can find the query in app/posts/[slug]/page.js, and you can add the links section to it like this:

Step 2: Use the new data in your rendering
Now your frontend should be fetching that new links data, but it’s still not doing anything with it. You have to modify the renderer too, which in this case is components/post-body.js. You’ll have to add an renderInlineRecord property to the <StructuredText/> component starting on line 7:

That’s just a basic example, modified from our docs about StructuredText.

That shows up on the frontend like this:

Of course, depending on what you want to do with those inlined links, you can modify the query and renderer accordingly. It just depends on what you’re doing with the content.

But that’s how it works with the starter project, as a basic example :slight_smile: Does that help?

If you can explain what you’re trying to accomplish (if not just playing around), we can help you more specifically.