- Issue created by @mbaycura
When I create a group type programmatically using GroupType::create(), then add fields to this group type, either programmatically or via the admin UI, these fields are not visible or editable in the group instance creation or edit form.
However, if I create a Group Type using the group admin UI, then add a number of fields via the admin UI, or programmatically, these fields are visible and editable in the group instance create/edit form.
Regardless of how the group types and fields were created they do exist in the database and are properly visible and configured on the Group Type 'edit', 'Manage Fields', `Manage form display` and `Manage display` forms. The only place they don't appear is on the group instance edit/create form. Which is an issue because there is no way for users to fill these fields out.
First we'll create a new group type using the group admin UI, add a field to it, then create an instance of that group.
Create a New Group Type using the admin UI called 'Studio Test' with machine name `studio_test`. NOTE: use this machine name because the `comic_studio` module will be programmatically adding a field to it.
Add a field to new 'studio_test' group type
Create new Group instance of the 'studio_test' group type
As one can see the 'blurb_test' field is properly visible and editable
Next let's install/enable the
`comic_studio` module attached →
to this issue submission.
This module will create two new group types called `studio` and `imprint`. This module also creates a field called `field_blurb` and attaches it to each of these group type. Finally this module will also programmatically add a field to the `studio_test` group type we created earlier using the group admin UI.
We now have Group Types - Studio Test, Studio, and Imprint
If we check out Studio Group Type we find that we indeed have a `blurb` field and `Example Field` created by the `comic_studio` module.
And when we review the 'Manage display form' and `Manage display` we see that we also have those fields properly configured to be visible and with valid widget definitions.
If we review the `studio_test` group type we created via the admin menus, we find it also now has the `Example Field` that we added using the comic_studio module, programmatically.
Now we'll create a group from the studio_test group type created via the admin UI, and `studio` group type created by the `comic_studio` module.
From 'Group List' -> Add Group -> choose 'Studio Test' group type.
We can see that we properly have a the `blurb test` field we created via the admin UI, as well as the `Example Field` that we added via the `comic_studio` module.
Now we'll create a new group of the 'Studio' group type.
From 'Group List' -> Add Group -> choose `Studio` group type
And we see that the `blurb` and `Example Field`, fields are not available to fill out at creation or during an edit.
This appears to be due to some difference in the creation of the group type from the admin UI and using the GroupType::create method.
// Create the 'studio' group type programmatically.
$studio_group_type = \Drupal\group\Entity\GroupType::create([
'id' => 'studio',
'label' => t('Studio'),
'description' => t('A collaborative space for members and media organization.'),
'creator_roles' => ['studio-admin'],
'creator_membership' => TRUE,
'creator_membership_form' => TRUE,
'is_active' => TRUE,
'creator_wizard' => TRUE,
]);
$studio_group_type->save();
We added the field `Example Field` to both the admin UI created Studio Test group type, and the Studio group type we created programmatically. We also verified that all of the fields are accessible, and configured via the form and view displays. So it seems like this is an issue specifically with how the Group Type is created programmatically.
Am I using the right methods for creating a group type in my module? Is there an additional step that I'm missing in the group type creation?
Drupal version used 10.3.5
Group Version Used 3.2.2