Skip to content

Commit

Permalink
Backport bugfix from master
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored and OskarStark committed Dec 15, 2020
1 parent 18dfcc4 commit 1578ead
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/Mapper/BaseGroupedMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/Form/FormMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 2 additions & 0 deletions tests/Show/ShowMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 1578ead

Please sign in to comment.