Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix display of M2A field values in render-template #23002

Closed
wants to merge 3 commits into from

Conversation

hanneskuettner
Copy link
Member

Scope

When trying to display M2A related fields in the related-values display, the render-template component is used which does not account for the field keys containing a item:<collection> part. The render-template receives, for example a value of

{
  "collection":"page_link",
  "id":1,
  "item": {
    "name":"Page Link",
    "page_id": {
      "title":"New Page"
     }
  }
}

and then, when trying to render the template {{collection}}: {{item:page_link.name}}{{item:external_link.name}}({{item:page_link.page_id.title}}) it tried to access the value with the key item:page_link.name which does not exist.

What's changed:

  • Strip out the collection identifier after the : if it is in the first field name of the field key. This allows for at least top level M2A fields to be rendered in the template. This currently does not extend support to work for M2A fields nested under a M2O.

Potential Risks / Drawbacks

  • N/A

Review Notes / Questions

  • N/A

Fixes #10601

Copy link

changeset-bot bot commented Jul 12, 2024

🦋 Changeset detected

Latest commit: 3098d8a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@directus/app Patch
@directus/api Patch
directus Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Member

@paescuj paescuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we enrich the item data via the related-values display with the collection prop, and then ensure in render-template that the data is only used if it matches the collection specified in the key?

That info seems to be missing at the moment (in contrast to your example), and without such a filtering, a key would match all linked collections (i.e. the collection part in item:<collection> has no effect).

@paescuj paescuj marked this pull request as draft August 18, 2024 22:17
@rijkvanzanten
Copy link
Member

Closing this to be revisited later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Many to Any nested content in related-values display
3 participants