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

[4.x]: Conditional fields not auto-refreshing on users/globals/orders etc #12348

Closed
CharlieGentle opened this issue Nov 18, 2022 · 5 comments
Closed
Assignees

Comments

@CharlieGentle
Copy link

What happened?

Description

Conditional fields don't work properly when on an element type that doesn't auto save. Elements must be manually saved for the fields to display.

Steps to reproduce

  1. Add lightswitch field to user.
  2. Add conditional field that is conditional on the lightswitch
  3. Go to a user and switch on/off the lightswitch

Expected behavior

Conditional field should show/hide based on switch.

Actual behavior

Conditional field doesn't show/hide until user is saved.

Craft CMS version

4.3.1

PHP version

8.1

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@CharlieGentle CharlieGentle changed the title [4.x]: Conditional fields not auto-refreshing on users/orders etc [4.x]: Conditional fields not auto-refreshing on users/globals/orders etc Nov 18, 2022
@brianjhanson brianjhanson self-assigned this Nov 18, 2022
@brianjhanson
Copy link
Contributor

This is working as expected at the moment. In order to determine which fields should be displayed (and update the UI) we need to save a draft. That means if autosaveDrafts is false the fields won't update automatically.

@CharlieGentle
Copy link
Author

This is fine for elements that autosave but the problem is that Globals, Users and Orders can't autosave.

@brianjhanson
Copy link
Contributor

Yeah, that's a limitation with the current implementation. In Craft 5 we plan to consolidate Globals and Singles which will enable support on that front. Orders and users are a bit more complicated and will require another solution.

@Michael-Paragonn
Copy link

I just wasted a bunch of time troubleshooting why my conditional fields were not updating, finally arriving here after almost reporting this as a bug with a 3rd-party plugin. 🥴

@brandonkelly Request: 🙏 If Auto-Save Drafts is disabled for a site/environment, add a little notice in the field conditions side panel noting that Auto-Save Drafts is needed for conditional fields to dynamically update... something like this:
image
Thanks!

brandonkelly added a commit that referenced this issue Sep 26, 2023
@brandonkelly
Copy link
Member

Good suggestion @Michael-Paragonn! Just released Craft 4.5.6 with that: (77930ee)

An Entry Condition setting, with a warning saying that `autosaveDrafts` must be enabled for the condition to take effect automatically.

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

No branches or pull requests

4 participants