diff --git a/Filter/FilterBuilderUpdater.php b/Filter/FilterBuilderUpdater.php index 1a943a6..7950ba7 100644 --- a/Filter/FilterBuilderUpdater.php +++ b/Filter/FilterBuilderUpdater.php @@ -129,7 +129,7 @@ protected function addFilters(FormInterface $form, QueryInterface $filterQuery, // this means we have a relation if ($child->getConfig()->hasAttribute('add_shared')) { - $join = trim($alias . '.' . $child->getName(), '.'); + $join = $child->getConfig()->getAttribute('filter_shared_name') ?? trim($alias . '.' . $child->getName(), '.'); $addSharedClosure = $child->getConfig()->getAttribute('add_shared'); @@ -150,7 +150,7 @@ protected function addFilters(FormInterface $form, QueryInterface $filterQuery, // Doctrine2 embedded object case } elseif ($formType instanceof EmbeddedFilterTypeInterface) { - $this->addFilters($child, $filterQuery, $alias . '.' . $child->getName()); + $this->addFilters($child, $filterQuery, $child->getConfig()->getAttribute('filter_field_name') ?? ($alias . '.' . $child->getName())); // default case } else { diff --git a/Filter/Form/FilterTypeExtension.php b/Filter/Form/FilterTypeExtension.php index 3697660..cee193d 100644 --- a/Filter/Form/FilterTypeExtension.php +++ b/Filter/Form/FilterTypeExtension.php @@ -30,6 +30,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) if (null !== $options['filter_field_name']) { $builder->setAttribute('filter_field_name', $options['filter_field_name']); } + + if (null !== $options['filter_shared_name']) { + $builder->setAttribute('filter_shared_name', $options['filter_shared_name']); + } } /** @@ -42,6 +46,7 @@ public function configureOptions(OptionsResolver $resolver) 'data_extraction_method' => 'default', 'filter_condition_builder' => null, 'filter_field_name' => null, + 'filter_shared_name' => null, )); } diff --git a/Resources/doc/filtertypeextension.md b/Resources/doc/filtertypeextension.md index f24032a..357ca9e 100644 --- a/Resources/doc/filtertypeextension.md +++ b/Resources/doc/filtertypeextension.md @@ -144,6 +144,10 @@ See [4.iii section](working-with-the-bundle.md#iii-customize-condition-operator) This option is used to define the field name on which the condition is applied. +##### The `filter_shared_name` option: + +This option is used to define the shared join name on which the condition is applied. + *** Next: [7. Working with other bundles](working-with-other-bundles.md)