Problem/Motivation
Field Group module doesn't catch the Redhen Contact form embedding process itself.
I'm trying to create field wrappers via Field Group on my "Account Registration" contact form display view mode, for the user register form.
I've added the wrappers, then go to "/user/register" and didn't see any effect.
Steps to reproduce
- Create form display view mode that will be used to embed to user register form.
- Go to "/admin/config/redhen/contact" and enable "Create a contact during user registration" checkbox, then set your view mode in the "Registration Contact Form" select.
- Go to your view mode, add some test fields and wrap them via field group feature.
- Go to User Register form and check result, you shouldn't see any field group element you added.
Proposed resolution
Add this code at the end of this function _redhen_contact_user_embed_contact_form()
.
// Field Group process when module exist.
if (\Drupal::moduleHandler()->moduleExists('field_group')) {
$context = [
'entity_type' => $contact->getEntityTypeId(),
'bundle' => $contact->bundle(),
'entity' => $contact,
'context' => 'form',
'display_context' => 'form',
'mode' => $form_mode,
];
field_group_attach_groups($form['redhen_contact_' . $contact->getType()], $context);
$form['redhen_contact_' . $contact->getType()]['#process'][] = [
FormatterHelper::class,
'formProcess',
];
$form['redhen_contact_' . $contact->getType()]['#pre_render'][] = [
FormatterHelper::class,
'formGroupPreRender',
];
}
Additional odd behavior
The embedded part of the form has a default form wrapper (title "General Contact information" in my case).
Details element has a parameter '#open' => TRUE,
but it displayed as closed when I test it with a code above.
So looks like we need an additional fix for this.
Thanks!