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]: Conditional fields are not working in a Matrix with autosaveDrafts set to false #15985

Closed
ajoliveau opened this issue Oct 31, 2024 · 3 comments
Assignees
Labels

Comments

@ajoliveau
Copy link

What happened?

Description

When I set autosaveDrafts to false, toggling a checkbox or a lightswitch, with conditional fields attached to its state, inside a matrix, doesn't work : the fields that are shown don't switch, and the call to /index.php?p=admin%2Factions%2Felements%2Fupdate-field-layout&v=1730400650789 returns a 400 with this output :

{
    "name": "Bad Request",
    "message": "Invalid element UUID: 8971f694-2b94-4d7b-bb61-3f49f742d244",
    "code": 0,
    "status": 400,
    "exception": "yii\\web\\BadRequestHttpException",
    "file": "/var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php",
    "line": 2140,
    "trace": [
        {
            "file": "/var/www/html/vendor/craftcms/cms/src/controllers/ElementsController.php",
            "line": 1880,
            "function": "_element",
            "class": "craft\\controllers\\ElementsController",
            "type": "->"
        },
        {
            "function": "actionUpdateFieldLayout",
            "class": "craft\\controllers\\ElementsController",
            "type": "->"
        },
      ...
    ]
}

This happens every time when autosaveDrafts is set to false, but I've also seen it happen a few times when it's enabled, but I haven't been able to really reproduce it in a repeatable way...

Steps to reproduce

  1. set autsaveDrafts to false
  2. Create a matrix with an entry type that contains a lightbox and two other fields, with conditional rules between the three
  3. In the CP create an entry, add the matrix, and try to toggle the switch with the devtools opened

Alternatively, here is a minimal github repo to easily reproduce it : https://github.com/ajoliveau/bug-conditional-craft
I only did :

  1. ddev config --project-type=craftcms --docroot=web
  2. ddev composer create -y "craftcms/craft"
  3. Changed the general/config.php file to disable autosaveDrafts
  4. Created a section, entry type, matrix field and the three fields

Expected behavior

Fields with conditional rendering conditions should work as intented

Actual behavior

Conditionals are not working

Craft CMS version

5.4.9

PHP version

8.2.24

Operating system and version

Linux 6.11.5-arch1-1

Database type and version

MariaDB 10.11.9

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

None

@i-just
Copy link
Contributor

i-just commented Nov 1, 2024

Hi, thanks for reporting! I raised a PR for this.

@brandonkelly
Copy link
Member

Craft 5.4.10 is out with that fix. Thanks again!

@ajoliveau
Copy link
Author

Thank you for the quick fix !

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

3 participants