craftcms / craftcms/cms

[4.x]: Twig template relation condition rules bug in a matrix field

Open
#13,269 1 comment 1 reaction 1 assignee View on GitHub

@i-just is already working on this.

Since Jun 2, 2023.

bug craft4
Dominant language
PHP
Stars
3.6k
Forks
705
Avg merge
1d 5h
Merged PRs (30d)
134

Description

What happened?
Description

When I set-up a Matrix field with one block with functionality as per #12679 , it works as expected: one relation-field filters the second. When I use this set-up on a second block, the page needs to be saved and refreshed before filters apply.

Steps to reproduce
  1. Make a matrix field with one block with 2 relation fields of entry types that are related to eachother.
  2. Test the matrix field and see the filter working
  3. Add another block with the same functionality
  4. See that the filter is only applied after saving / refreshing
Expected behavior

When I have two relation-fields, I want to select the first one, which then acts as a filter for the second one. When the first one is selected, the second one must be filtered on opening.

Actual behavior

This works flawlessly when I have this set-up on only one of the matrix blocks I created. When I add this functionality to a second block, the filter stops working on both blocks, until I save the project and the page reloads, then the second field is filtered again.

https://github.com/craftcms/cms/assets/6756174/67f387e5-4dfd-4def-8a77-245f1cc4a8fd

Craft CMS version

4.4.13

PHP version

8.1

Operating system and version

No response

Database type and version

Mysql

Image driver and version

No response

Installed plugins and versions

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.