Skip to content

Commit

Permalink
Fix not setting field_name when filtering (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Sep 22, 2021
1 parent 7315a8c commit 855bd55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Builder/DatagridBuilder.php
Expand Up @@ -81,7 +81,7 @@ public function fixFieldDescription(FieldDescriptionInterface $fieldDescription)
$fieldDescription->setOption('parent_association_mappings', $fieldDescription->getOption('parent_association_mappings', $fieldDescription->getParentAssociationMappings()));
}

$fieldDescription->setOption('name', $fieldDescription->getOption('name', $fieldDescription->getName()));
$fieldDescription->setOption('field_name', $fieldDescription->getOption('field_name', $fieldDescription->getFieldName()));

if ($fieldDescription->describesAssociation()) {
$fieldDescription->getAdmin()->attachAdminClass($fieldDescription);
Expand Down
9 changes: 9 additions & 0 deletions tests/Builder/DatagridBuilderTest.php
Expand Up @@ -231,4 +231,13 @@ public function testAddFilterWithType(): void

static::assertSame(ModelFilter::class, $fieldDescription->getType());
}

public function testFixFieldDescriptionSetsFieldName(): void
{
$fieldDescription = new FieldDescription('name', [], [], [], [], 'fieldName');

$this->datagridBuilder->fixFieldDescription($fieldDescription);

static::assertSame('fieldName', $fieldDescription->getOption('field_name'));
}
}

0 comments on commit 855bd55

Please sign in to comment.