Problem/Motivation
When creating a new 2.x group type, if an admin role isn't automatically created, the following error appears when editing the group type.
Warning: Undefined array key "creator_roles" in Drupal\group\Entity\Form\GroupTypeForm->form() (line 241 of modules/contrib/group/src/Entity/Form/GroupTypeForm.php).
Drupal\group\Entity\Form\GroupTypeForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('group_type_edit_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 270)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Warning: Undefined array key "#description" in Drupal\group\Entity\Form\GroupTypeForm->form() (line 241 of modules/contrib/group/src/Entity/Form/GroupTypeForm.php).
Drupal\group\Entity\Form\GroupTypeForm->form(Array, Object) (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('group_type_edit_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 270)
Drupal\shield\ShieldMiddleware->bypass(Object, 1, 1) (Line: 137)
Drupal\shield\ShieldMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
- Create a new group type by navigating to
/admin/group/types/add - Under "Access settings" make sure the "Automatically configure useful default roles" and "Automatically configure an administrative role" options are unchecked.
- Click the "Save group type" button to save the new group type.
- Navigate to the edit form of the newly created group type. Example:
/admin/group/types/manage/test - The error message should display.
Proposed resolution
Error should not display.
Remaining tasks
N/A
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | group-form-error-3364226-12.patch | 807 bytes | gwvoigt |
| #4 | group-form-error-3364226-0.patch | 893 bytes | gwvoigt |
| #3 | SS-Not-reproducable.png | 254.2 KB | sahil.goyal |
| Screenshot 2023-06-01 at 11.36.58 AM.png | 285.21 KB | pcate |
Issue fork group-3364226
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pavelculacov commented+ 1 Problem persist.
Not always description exists in creator_roles.
$form['creator_roles']['#description'] .= "
$description";
Comment #3
sahil.goyal commentedHi @Pcate, I have been looked to the issue, as followed the mentioned steps to reproduce the issue, but when navigating to the newly created group type, not any error message get displayed. Could you please more information about the issue, Attaching screenshot shown no error message getting displayed.
Comment #4
gwvoigtI'm having the same issues on 3.1.0, this patch should check for the array key that is throwing the error before accessing it.
Comment #5
dbielke1986 commentedWe have the same on our page, so we need to wait for the fix and stay with 1.5.
But I will try the patch, @gwvoigt.
Comment #6
gwvoigtThe patch should work with 2.1.0 as well.
Comment #7
pcate commentedI can confirm the patch applies to Group 2.1 and resolves the error message.
Comment #8
vincent.hoehnWe can confirm that the patch works with 2.1. Thanks!
Comment #9
chop commentedQueued tests of patch from #4 with Group v2.1.x
Comment #10
chop commentedThis might be expressed more simply using
Comment #11
chop commentedComment #12
gwvoigtThanks chOP, I'm adding anew patch with your suggestion
Comment #14
gorkagr commentedHi!
Thanks for the patch. I can confirm it works as well on the 3.2.0 version too.
Best,
Comment #16
kristiaanvandeneyndePatch workflow is no longer supported as the project has moved to GitLab. Also, the fix suggested here would not work as, if you look about 10 lines higher, it was clearly intended as an extension of the render array element defined above. I've gone ahead and updated the MR to 2.3.x so we can get pipelines to run. Will then commit to 2.2.x/2.3.x/3.2.x/3.3.x once people confirm it's working.
Comment #17
gorkagr commentedHi @kristiaanvandeneynde
New patch works fine at least in 3.2.2 :)
thnks
Comment #20
kristiaanvandeneyndeWill backport to x.2.x
Comment #21
kristiaanvandeneynde