Several instances of same global field definition (fieldsnippet)


#1

It should be possible to have more than one instance of a global field definition or fieldsnippet shouldn’t it?

This is my Gfieldef:

type: group
fields:
	i_text:
		label: Introduction
		type: textarea
		buttons: false
		validate:
			maxLength: 300

and in a blueprint I call it as:

intro: 
	extends: intro

and it works, but If I attempt to use two of them:

intro: 
	extends: intro

intro2: 
	extends: intro

It just renders one of them. If I change the label:

intro: 
	extends: intro
	fields:
		i_text:
			label: something

intro: 
	extends: intro
	fields:
		i_text:
			label: somethingelse

…only one field with the second label shows.

Is this not possible at all?

Thank you


#2

This has been asked before. No, it’s not possible. Why? Because you end up with the same field names being used multiple times. And since you can’t do it without groups, it doesn’t make sense within groups, either.


#3

Thank you,

I searched but could not find any posts.

In my case it is possible, since I am using a single field in my fieldef, as long as I don’t declare it as a group, so

‘fields/intro.yml’

label: Introduction
type: textarea
buttons: false
validate:
  maxLength: 300

and in the bp:

intro1: intro
intro2: 
  extends: intro
	label: intro2

:tada:


#4

Yes, that is possible because your fields then have different names, if you need repeating fieldsets, you can use a structure field or modules, as suggested in the other post.