craftcms / cms

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

[5.x]: Multi-instance Asset field disappears after 3 uses #15109

Closed TGriffiths88 closed 5 months ago

TGriffiths88 commented 5 months ago

What happened?

Description

I have an entry type where I am reusing several fields to build out a layout. One of the re-used fields is an asset field, and when used 3 times, the field then disappears from the list of available fields.

Steps to reproduce

  1. Create a section and entry type
  2. Create an asset field
  3. Add the asset field to the entry type multiple times, adding new handles in settings as required
  4. Once you hit 3 instances of the field, you should see its no longer available in the field list

Expected behavior

I would expect the field to be reusable, and available to reuse

Actual behavior

The field disappears from the list

Craft CMS version

Craft Pro 5.1.7

PHP version

8.3.6

Operating system and version

Mac OSX 13.4.1

Database type and version

MySQL 8.0.33

Image driver and version

Imagick 3.7.0 (ImageMagick 6.9.11-60)

Installed plugins and versions

Algolia | 5.0.0 Blitz | 5.3.1 CKEditor | 4.0.6 DigitalOcean Spaces Filesystem | 3.0.0-beta.1 Hyper | 2.0.0 Postmark | 3.1.0 Retour | 5.0.0 Scout | 5.0.0-beta.1 SEOmatic | 5.0.3 Sprig | 3.0.2 Wishlist | 3.0.0

i-just commented 5 months ago

Hi, thanks for reporting!

The Assets field is not multi-instance, and it shouldn’t be possible to add it to a single layout more than once (the same goes for all other relational fields and matrix field).

There was a very similar bug, which was fixed in 5.0.0-beta.2, but I cannot replicate that on 5.1.7. Any chance you can provide more info on how you were able to add multiples of the same assets field to a single layout?

TGriffiths88 commented 5 months ago

Thanks @i-just, okay that makes sense.

I was working in 5.1.2 when I initially created that layout, and I upgraded to 5.1.7 to see if that resolved the issue. Perhaps 5.1.2 will allow you to add multiple instances?

Heres versions from composer.json before updating

"craftcms/ckeditor": "4.0.4",
"craftcms/cms": "5.1.2",
"craftcms/postmark": "^3.1",
"nystudio107/craft-retour": "5.0.0",
"nystudio107/craft-seomatic": "5.0.2",
"putyourlightson/craft-blitz": "5.3.0",
"putyourlightson/craft-sprig": "3.0.1",
"studioespresso/craft-scout": "^5.0.0-beta.1",
"trendyminds/algolia": "^5.0.0",
"vaersaagod/dospaces": "3.0.0-beta.1",
"verbb/hyper": "2.0.0-beta.8",
"verbb/wishlist": "^3.0.0",
"vlucas/phpdotenv": "^5.6.0"

Let me know if you still cant reproduce and I will do some more digging my end.

i-just commented 5 months ago

Thanks, @TGriffiths88, that’s very helpful! Unfortunately, I still can’t reproduce adding multiples of assets field to a single layout.

brandonkelly commented 5 months ago

Is there a chance that the field started off with a different field type (which did support multiple instances) and then was converted to an Assets field later?

Or perhaps the field layout config YAML was modified manually to include the field multiple times?

In any case, going to close this issue as it’s (now) working as expected :)