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

[5.x]: Some ambiguity regarding entry conditions #14919

Open
corneliusio opened this issue May 1, 2024 · 2 comments
Open

[5.x]: Some ambiguity regarding entry conditions #14919

corneliusio opened this issue May 1, 2024 · 2 comments
Labels

Comments

@corneliusio
Copy link

corneliusio commented May 1, 2024

What happened?

EDIT:
I have realized a major mistake on my part which is that users have sections for "Current User Condition" AND "User Condition". I used the wrong section and the user conditions are working as expected.

I'm also starting to wonder if the Matrix conditional is potentially an issue of ambiguous language and a fundamental difference between how Neo handles field conditionals and how matrix blocks in Craft 5 handle them. Where the "Entry Condition" options don't apply to the OWNER, but to the matrix entry type itself. However, if that is the case, I don't understand the existence of the "Entry Type" option in the dropdown since, as far as I can tell, this would NEVER change.

Description

Feeling a bit crazy here because no one else has reported. But all my tests point to certain field conditions just not working. Below is a link to a repo for reproduction—project was setup using instruction at https://craftcms.com/docs/5.x/install.html. There may be more, but these are the two cases I've tested.

https://github.com/corneliusio/craft-example

Project has the following:

  1. Two sections, Home and Pages
  2. Two entry types, Matrix Type and Page Type
  3. Two fields, Plain Text and Matrix
  4. One user group, Group

Steps to reproduce

First conditional issue:

There is a field layout panel called "Foobar" for users with a single field and the following condition:
Current User Condition: "User Group" "is one of" "Group"

Second conditional issue:

The "Matrix Type" entry type has a single, plain text field, "Field", and the following condition:
Entry Condition: "Section" "is one of" "Pages"

The "Matrix" field allows "Matrix Type" entry types as elements, has been added to the "Page Type" entry type, and "Page Type" is assigned to both the "Home" and "Pages" sections.

Expected behavior

First conditional issue:

When a user belongs to the "Group" user group, the "Foobar" field layout tab would display when editing that user.

Second conditional issue:

When adding matrix blocks to the "Home" section, the "Field" field on the matrix block should not display.
When adding matrix blocks to the "Pages" section, the "Field" field on the matrix block should not display.

Actual behavior

First conditional issue:

If you add a user to the User Group "Group" and edit that user the "Foobar" panel does not display.

Second conditional issue:

When adding instances of the "Matrix Type" in the "Matrix" field for a "Page Type", the plain text field does not appear for either the "Home" or "Pages" sections.

Craft CMS version

5.1.0

PHP version

8.3

Operating system and version

Linux 6.7.11

Database type and version

MySQL 8.0.33

Image driver and version

Imagick 3.7.0

@corneliusio corneliusio added the bug label May 1, 2024
@thupsi
Copy link

thupsi commented May 1, 2024

I think the described behaviour is not a bug, it's just that conditions here do not work as you expect them to:

  • The "Current User Condition" applies to the user editing the current element. So if you are editing a user, you should be in the "Group" user group to display the "Foobar" tab. You should use the "User Condition" instead.
  • Likewise the "Entry Condition" applies to the current entry. In your case that is the Matrix block, not the parent entry. I agree that is perhaps a little confusing. I also think it would be usefull to add a new "Parent Entry Condition" for nested elements.

EDIT:
Oops! Just saw you edit at the top 🙂

@corneliusio
Copy link
Author

corneliusio commented May 1, 2024

@thupsi All good. I think you're right in that I was mistaken about this being a bug, but I do think there may be an issue here to address regarding the Entry Condition given the one-two punch of ambiguous language and the number of people that will be coming from Neo where you could set conditions based on the block owner.

Also still really perplexed by the "Entry Type" option if this is the expected functionality, but I do think that being able to apply conditions based on the owner of an entry type within a field would be extraordinarily helpful. Though, this may just be an argument to continue using Neo blocks (presuming they still have this feature in Craft 5). Given the architectural changes in Craft 5, I would not be surprised to find out it is a non-trivial addition to allow conditions based on "owner" since I'm not entirely sure the concept of an owner carries over here.

That said, there are a ton of use cases for this and would love to see the ability to allow matrix fields to be conditional based on the context of the matrix field itself.

@corneliusio corneliusio changed the title [5.x]: At least some conditions seem broken [5.x]: Some ambiguity regarding entry conditions May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants