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

  1. Create a new group type by navigating to /admin/group/types/add
  2. Under "Access settings" make sure the "Automatically configure useful default roles" and "Automatically configure an administrative role" options are unchecked.
  3. Click the "Save group type" button to save the new group type.
  4. Navigate to the edit form of the newly created group type. Example: /admin/group/types/manage/test
  5. 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

Issue fork group-3364226

Command icon 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

PCate created an issue. See original summary.

pavelculacov’s picture

+ 1 Problem persist.
Not always description exists in creator_roles.
$form['creator_roles']['#description'] .= "
$description";

sahil.goyal’s picture

Status: Active » Needs review
StatusFileSize
new254.2 KB

Hi @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.

gwvoigt’s picture

StatusFileSize
new893 bytes

I'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.

dbielke1986’s picture

We 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.

gwvoigt’s picture

The patch should work with 2.1.0 as well.

pcate’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm the patch applies to Group 2.1 and resolves the error message.

vincent.hoehn’s picture

We can confirm that the patch works with 2.1. Thanks!

chop’s picture

Queued tests of patch from #4 with Group v2.1.x

chop’s picture

+++ b/src/Entity/Form/GroupTypeForm.php
@@ -238,7 +238,11 @@ class GroupTypeForm extends BundleEntityFormBase {
+        if (array_key_exists('creator_roles', $form)) {
+          if (array_key_exists('#description', $form['creator_roles'])) {

This might be expressed more simply using

if (isset($form['creator_roles']['#description'])) {
chop’s picture

Version: 2.1.0 » 2.1.x-dev
gwvoigt’s picture

StatusFileSize
new807 bytes

Thanks chOP, I'm adding anew patch with your suggestion

gorkagr’s picture

Hi!

Thanks for the patch. I can confirm it works as well on the 3.2.0 version too.
Best,

kristiaanvandeneynde made their first commit to this issue’s fork.

kristiaanvandeneynde’s picture

Status: Reviewed & tested by the community » Needs review

Patch 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.

gorkagr’s picture

Hi @kristiaanvandeneynde

New patch works fine at least in 3.2.2 :)
thnks

kristiaanvandeneynde’s picture

Status: Needs review » Fixed

Will backport to x.2.x

kristiaanvandeneynde’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.