diff --git a/src/Mapper/BaseGroupedMapper.php b/src/Mapper/BaseGroupedMapper.php index 1e9d3fcf6d..dc3c5f3d51 100644 --- a/src/Mapper/BaseGroupedMapper.php +++ b/src/Mapper/BaseGroupedMapper.php @@ -329,10 +329,16 @@ protected function addFieldToCurrentGroup($fieldName) protected function getCurrentGroupName() { if (!$this->currentGroup) { - $this->with($this->admin->getLabel(), [ - 'auto_created' => true, - 'translation_domain' => $this->admin->getTranslationDomain(), - ]); + $label = $this->admin->getLabel(); + + if (null === $label) { + $this->with('default', ['auto_created' => true]); + } else { + $this->with($label, [ + 'auto_created' => true, + 'translation_domain' => $this->admin->getTranslationDomain(), + ]); + } } return $this->currentGroup; diff --git a/tests/Form/FormMapperTest.php b/tests/Form/FormMapperTest.php index 4c47c8537a..1094470314 100644 --- a/tests/Form/FormMapperTest.php +++ b/tests/Form/FormMapperTest.php @@ -534,6 +534,8 @@ public function testAddOptionRole(): void $this->assertTrue($this->formMapper->has('bar')); $this->assertFalse($this->formMapper->has('quux')); + $this->formMapper->end(); // Close default + $this->formMapper ->with('qux') ->add('foobar', 'bar', [], ['role' => self::DEFAULT_GRANTED_ROLE]) diff --git a/tests/Show/ShowMapperTest.php b/tests/Show/ShowMapperTest.php index cffbf599a0..333b82825f 100644 --- a/tests/Show/ShowMapperTest.php +++ b/tests/Show/ShowMapperTest.php @@ -533,6 +533,8 @@ public function testAddOptionRole(): void $this->assertTrue($this->showMapper->has('bar')); $this->assertFalse($this->showMapper->has('quux')); + $this->showMapper->end(); // Close default + $this->showMapper ->with('qux') ->add('foobar', 'bar', ['role' => self::DEFAULT_GRANTED_ROLE])