craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.22k stars 627 forks source link

[5.x]: Defaults on multi-select fields not functional in Matrix nested entries #15756

Closed gateszies closed 1 day ago

gateszies commented 2 days ago

What happened?

Description

When dealing with nested entries in a Matrix, defaults on multi-select fields are not being correctly saved or stored when saving their parent entry. This leads to large errors on the authoring end and disables the ability to use defaults.

Steps to reproduce

  1. Create a Matrix field with nested entry types

    Screenshot 2024-09-18 at 4 04 06 PM
  2. Add a multi-select field to the entry type, ie Radio, Dropdown and select a default value

    Screenshot 2024-09-18 at 4 03 04 PM
  3. In a page that contains that Matrix field, add entry type from dropdown. You can see that the defaults are correctly selected here. Don't interact with any of the fields and hit Create entry.

    Screenshot 2024-09-18 at 4 07 01 PM
  4. Hit Save on the parent entry and get error messages about validation error in nested entry. These fields have defaults set and previously showed those defaults selected, but after saving the parent entry you can see the defaults have been cleared and nothing is selected.

    Screenshot 2024-09-18 at 4 09 25 PM

Expected behavior

The defaults of multi-select fields in nested entries should remain selected after creating a nested entry and saving the parent entry without having to define them manually.

Actual behavior

The defaults of multi-select fields in nested entries are cleared after saving parent entries. This throws an error and disables the actual usage of defaults for the author.

Craft CMS version

5.4.0.1

PHP version

8.2.23

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Screenshot 2024-09-18 at 4 15 34 PM
gateszies commented 2 days ago

Similar issue was reported over here 👀

i-just commented 1 day ago

Hi, thanks for getting in touch! It sounds like a duplicate of https://github.com/craftcms/cms/issues/15706. If you update to 5.4.4, it should be fixed.