Reusing Multiple Fields

Hi!

I was wondering if there’s already a way to re-use a group of fields. In my current project I have several groups of fields that are being used on different templates. For Example: an address group, consisting of street, house number, zip code, city and a country select. Or SEO-Fields (meta-fields, some text-area, html-title etc)

It’d be great if I could somehow define the fields in a way similar to global field definitions.

Thinking about something like:

// /site/blueprints/fields/address.yml
fields:
  street:
    label: Street
    type: text
    width: 3/4
    
  house_number:
    label: Housenumber
    type: text
    width: 1/4

  zipcode:
    label:
      de: PLZ
      en: Zipcode
    type: text
    width: 1/4

  city:
    label:
      de: Stadt
      en: City
    type: text
    width: 3/4

And then in the template-blueprint:

fields:
  title:
    label: Title
    type: text
  date:
    label: Date
    type: date
    
  import: address

Though this still has a few problems, like: what about multiple imports? What about fields actually called import?

Currently it seems the closest one can get is to use structure for this and limit it to 1… but that is not ideal – unless it was possible to change the “No entries yet” - “Add the first entry” text :thinking:

Currently, this is not possible. A structure field is an option, but I wouldn’t use it for that purpose because of the modal. You could either create a field definition for each field and copy/paste the whole stuff. Or create a custom field.

Yup, currently I’m using

street: street
zipcode: zipcode
city: city

in all the relevant blueprints. It works, but it’d be REALLY neat if this was even more DRY. :slight_smile:

Yes, I know, we all do it that way, I guess. Not ideal. But makes it easier to extend fields. Maybe that’s one reason why it hasn’t been implemented yet.

This has been requested multiple times: Blueprint groups