4

Coming from Wordpress and using ACF plugin...it's really nice to be able to have say a field group called "SEO Fields" that contains all the custom fields for SEO needs (title, description, OG stuff, etc) and then maybe another group called "Hero" that contains fields needed to create a Hero area -- and then be able to easily say "show these fields on the following content types."

I know I can re-create the field functionality easily using the custom fields in Craft...but it seems SUPER kludgy to have create the same tabs in the fields layout area for every single new section that I create for the site and then have to drag all the needed fields over every time. Is there not a way to save these as "groups" or something and then be able to drag an entire group over to the "Field Layout" area when creating/editing the Entry Type?

UPDATE: I've marked the answer below as correct, and I've opened a feature request on the Craft github discussions page if anyone would like to follow it or upvote it.

1 Answer 1

2
+50

This is currently not possible in Craft. You can group fields into field groups, but those are only used for organizational purposes.

If you care about this feature, you can suggest it as a feature request in the discussion section on Github. This allows other people to upvote the idea – a feature request with lots of upvotes is more likely to get implemented in future versions of Craft.

If you only care about speeding up the creation of new entry types with a common set of fields, there's already a feature request to allow batch editing in the field layout designer. If this is what you're going for, make sure to upvote the feature request and provide ideas on how this could be implemented. Perspectives of developers coming from other systems are always great for this. This feature could be integrated with the existing concept of field groups – for example, by providing a single button to add all fields in a particular field group to the field layout.


In some systems there's another 'flavour' of field groups, where the group isn't just an organizational taxonomy, but acts as an extra layer between an element and the grouped fields. In your example, you could create a field group header which is comprised of a set of nested fields and can be added wholesale to field layout. In this case, the fields would usually be accessed as entry.header.headline instead of entry.headline. This has the nice benefit of allowing you to use the same field multiple times in the same field layout, by nesting them in different groups. Also, you can modify the field group in one place and any changes immediately apply to all entry types where the field group is used.

This isn't currently possible in Craft – if you want something like this, maybe post it as a separate discussion. I'd certainly upvote it, as it's something I'm missing as well.

For reference, ProcessWire provides a FieldsetGroup field as part of the commercial ProFields module which works exactly like that.


Another option for right now is to make your content more granular, reducing the need to put the same fields in multiple enty types. In your example, you could create a section header with an entry type that contains all your header fields. Then your editors could create header entries separately and associate them with a particular page using an Entries field. Using this approach, only one entry type needs all the fields you need for your header group, and all entry types that need to have a header just require the entries field. Conceptually, this is close to the field groups mentioned above.

Of course, whether this makes sense depends heavily on context. In this example, it would enable header reuse but make editing a bit more indirect and cumbersome. It's all a matter of trade-offs.

3
  • thanks for the thorough answer. I'll definitely put in a request as you mentioned. The approach you mention last is interesting. Would you use a "Channel" section type? How would you go about restricting URLs to those entries so they wouldn't be viewable/navigable at say website.com/headers/header1 ? Is there an easy way to do that in Craft inside the entry that I'm not aware of, or you just setup a template that redirects to 404 or redirects in htaccess or what? Thanks! Feb 8 at 16:18
  • 1
    @kevindeleon Drop a link to the discussion once you've opened it, I'll be the first to upvote! Yes, I'd use a channel in most cases – unless it makes sense to structure the 'pseudo field group' hierarchically, then you could use a structure. Regarding URLs, sections don't have public URLs by default unless you define them in the section's settings. Simply leave the URI and Template settings for that section blank, then those entries won't be publicly accessible and can be used as 'data silos'.
    – MoritzLost
    Feb 8 at 16:26
  • 1
    Ok cool. Didn't realize those could be left blank and therefor be "private" so to speak. Thanks again man. I created the discussion for the new feature here: github.com/craftcms/cms/discussions/10501 Feb 8 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.