Stillat / relationships

Provides automated bi-directional @statamic entry relationships
MIT License
16 stars 1 forks source link

Having issues with Many taxonomy terms to One entry #39

Closed sebszocinski closed 2 months ago

sebszocinski commented 2 months ago

I am setting up a festival website where I have a taxonomy called "Festival" which has a list of terms for each year, for example 2022, 2023, 2024. Each "Year" term has a Relationship Field to entries from a "Events" collection. So 2022 (term) can have MANY events, and each Event (entry) can only have ONE year (term).

This is my setup:

Relate::manyToOne(
    'term:festival.events',
    'events.festival'
);

The taxonomy term blueprint has no max_items set, but the Events entry blueprint has max_items: 1 for the term relationship.

The taxonomy term is not populating with Events (entries) when I create/import them that are correctly linked to the year term.

I've tried running php please relate:fill and have also tried swapping manyToOne with oneToMany and flipping the order but that doesn't work either.

I have this working fine with Entry to Entry relationships that are manyToMany.

Help!

JohnathonKoster commented 2 months ago

Hi there, would you be able to also share your blueprints? I can take a look at this sometime this upcoming weekend to see what's going on 👍

sebszocinski commented 2 months ago

taxonomies/festival/festival.yaml

...
  events:
    display: Events
    sections:
      -
        display: Events
        fields:
          -
            handle: events
            field:
              mode: default
              create: true
              collections:
                - events
              type: entries
              display: Events
              listable: hidden
              instructions_position: above
              visibility: visible
              replicator_preview: true
              hide_display: false
...

collections/events/event.yaml

...
  sidebar:
    display: Sidebar
    sections:
      -
        fields:
          -
            handle: festival
            field:
              max_items: 1
              mode: typeahead
              create: true
              taxonomies:
                - festival
              type: terms
              display: Festival
              listable: hidden
              instructions_position: above
              visibility: read_only
              replicator_preview: true
              hide_display: false
...
JohnathonKoster commented 2 months ago

Fix available in 2.1.7 👍