BKaernel's picture

Hello. I know that it is possible to reuse fields. 
But apparently that is not possible with field groups;
Just to get confirmation of this. 

I create a group called 'group_image_cover' with two field : 

  • field_image
  • field_active with class"element-invisible" when is inactive

It would be interesting to use it for my content PAGE and ARTICLE.
But i don't think it's possible. I recreate a group in each content-type. 
If you see a better way ?
 

One more thing. 
The group doesn't seem to be called along with the fields. 
For exemple : $content['group_image_cover']['field_image']
I just called : $content['field_image']
Is that normal?

Accepted answer

It would be interesting to use it for my content PAGE and ARTICLE.
But i don't think it's possible. I recreate a group in each content-type. 
If you see a better way ?

I know you can reuse groups between the form and display modes within a content type, but as the form config and display mode config are specific to each content type, then I'm fairly sure it would be very difficult to share group config with other content types.

One more thing. 
The group doesn't seem to be called along with the fields. 
For exemple : $content['group_image_cover']['field_image']
I just called : $content['field_image']
Is that normal?

Yes, I see that in a hook_preprocess_node() implementation. However, if you look in $variables['elements'] you'll see a definition a bit like this:

Comments

It would be interesting to use it for my content PAGE and ARTICLE.
But i don't think it's possible. I recreate a group in each content-type. 
If you see a better way ?

I know you can reuse groups between the form and display modes within a content type, but as the form config and display mode config are specific to each content type, then I'm fairly sure it would be very difficult to share group config with other content types.

One more thing. 
The group doesn't seem to be called along with the fields. 
For exemple : $content['group_image_cover']['field_image']
I just called : $content['field_image']
Is that normal?

Yes, I see that in a hook_preprocess_node() implementation. However, if you look in $variables['elements'] you'll see a definition a bit like this: