From 9b2002a5ffee401d63699018f933fd2238dd3fe2 Mon Sep 17 00:00:00 2001 From: Daniel Gorgan Date: Wed, 7 Oct 2020 09:21:22 +0300 Subject: [PATCH] Add filter_field_name option (#334) --- Filter/FilterBuilderUpdater.php | 2 +- Filter/Form/FilterTypeExtension.php | 1 + Resources/doc/filtertypeextension.md | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Filter/FilterBuilderUpdater.php b/Filter/FilterBuilderUpdater.php index 96a6468..1a943a6 100644 --- a/Filter/FilterBuilderUpdater.php +++ b/Filter/FilterBuilderUpdater.php @@ -176,7 +176,7 @@ protected function getFilterCondition(FormInterface $form, AbstractType $formTyp { $values = $this->prepareFilterValues($form, $formType); $values += array('alias' => $alias); - $field = trim($values['alias'] . '.' . $form->getName(), '. '); + $field = $form->getConfig()->getAttribute('filter_field_name') ?? trim($values['alias'] . '.' . $form->getName(), '. '); $condition = null; diff --git a/Filter/Form/FilterTypeExtension.php b/Filter/Form/FilterTypeExtension.php index b65df3e..5750f34 100644 --- a/Filter/Form/FilterTypeExtension.php +++ b/Filter/Form/FilterTypeExtension.php @@ -37,6 +37,7 @@ public function configureOptions(OptionsResolver $resolver) 'apply_filter' => null, 'data_extraction_method' => 'default', 'filter_condition_builder' => null, + 'filter_field_name' => null, )); } diff --git a/Resources/doc/filtertypeextension.md b/Resources/doc/filtertypeextension.md index 1c3f719..f24032a 100644 --- a/Resources/doc/filtertypeextension.md +++ b/Resources/doc/filtertypeextension.md @@ -140,6 +140,10 @@ This option is expected to be closure and recieve one parameter which is an inst See [4.iii section](working-with-the-bundle.md#iii-customize-condition-operator) for examples. +##### The `filter_field_name` option: + +This option is used to define the field name on which the condition is applied. + *** Next: [7. Working with other bundles](working-with-other-bundles.md)