Any plans for a Relation field?

Are there any plans to create a Relation type field? So you can add a reference to an item in a collection to create a carousel etc?

Enjoying playing with Tina. It’s very cool.

Hi! There’s no plans to create out-of-the-box reference field. The reason is that there is no one-way to do references. It’s dependent on how your website works. But it’s definitely possible to create a custom field plugin for handling references. We don’t have any example guides on how to do this, but you can learn how to create custom Field Plugins in this blog post.

There’s also a Select component that you can import from tinacms. This might look something like:

import { Select } from "tinacms"
import { useReferenceList } from "./my-custom-reference-hooks"

cms.fields.add({
  name: "reference",
  Component(props) {
    const { loading, data: options } = useReferenceList() 

    if (loading) return "..."    

    return <Select {...props} options={options} />
  }
})

Hi there! I’ve just published an article that covers this in detail, also I provide a Gist as a boilerplate:

2 Likes