craftcms / cms

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

[5.x]: Matrix fields not reusable in field layout designer #14443

Closed turnstylerj closed 6 months ago

turnstylerj commented 6 months ago

What happened?

Description

In the field layout designer where fields can now be re-used with custom handles, Matrix fields still disappear when they're dragged into the field layout.

Steps to reproduce

  1. Add a Matrix field to an entry type's field layout

Expected behavior

Matrix field persists in the available field options and is able to be re-used with a new handle.

Actual behavior

Matrix field disappears from available field options.

Craft CMS version

5.0.0-beta.2

PHP version

8.2.13

Operating system and version

Linux 5.15.68-0-virt

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

"craftcms/ckeditor": "4.0.0-beta.6" "nystudio107/craft-seomatic": "5.0.0-beta.5"

brandonkelly commented 6 months ago

That’s expected. Only fields that store content in the content table are reusable within a field layout.

satcreative commented 6 months ago

This is also the case with CKEditor fields. Are they also not expected to be reuseable?

brandonkelly commented 6 months ago

CKEditor fields are a bit of an edge case because, while they do store content in the content column, they also manage nested entries. The way it works right now, some nested entries would end up getting deleted unexpectedly when saving, if they were multi-instance. So they are single-instance for the time being. It should be possible for us to make multi-instance work for them, though.

MattWilcox commented 6 months ago

Can I say that from the perspective of someone building out a site, this limitation feels like a bug.

"I thought we didn't have to make redundant duplicated fields anymore; why is this broken for Matrix fields?" is what that feels like.

brandonkelly commented 6 months ago

CKEditor 4.0.0-beta.8 is out now with multi-instance support 🎉

MattWilcox commented 6 months ago

Just to clarify, as I've have been getting myself into knots with fields/entry-type/matrix since going deeper into scaffolding out Craft5... this fix is for allowing multiple instances of a CKeditor field in an Entry Type, and not Matrix? So we can not pull in multiple instances of a single matrix-field into an Entry Type still, but now we can have multiple instances of a single CKEditor field in an Entry Type?

brandonkelly commented 5 months ago

@MattWilcox Correct. Just mentioning it here since it came up in the discussion.

dolphiq-allard commented 4 months ago

First off, Craft 5 has some great improvements such as which reusing fields.

In regards to not being able to reuse matrix fields: same goes for the entries field. It would be great if these could be reused as well. I tend to allow our clients to select entries for e.g. the Contact page, privacy statement and disclaimer for use in various templates. If the entries field would be reusable this would save me creating separate fields for these items.

humandevs commented 3 months ago

+1 for this feature. This would be super awesome!

Content reuse is a big selling point of other "expensive" Composable CMS platforms such as Contentful, and even Enterprise Content Management systems like MadCap or Paligo. This follows the DRY (Don't Repeat Yourself) principle. Being able to find (search for) and insert nested, re-useable, atomic (matrix/neo fields) content in the GUI, would be great, and could let us keep one of our growing projects in Craft where this has been a consistent pain point for content creators dealing with knowledge-base content for related products.

For some examples/ideas from the "super duper expensive" CCMS/ECM platforms, here's how Contentful content re-use works: https://training.contentful.com/student/page/792577-reusing-content-across-compose And Paligo: https://paligo.net/content-reuse/ (although this is a deep-copy and not a true instance)

brandonkelly commented 3 months ago

@dolphiq-allard @humandevs See https://github.com/craftcms/cms/discussions/8497#discussioncomment-9525050.