spiriitlabs / form-filter-bundle
Symfony bundle for dynamic filtering, search forms and Doctrine query generation
Package info
github.com/SpiriitLabs/form-filter-bundle
Type:symfony-bundle
pkg:composer/spiriitlabs/form-filter-bundle
Requires
- php: ^8.1
- doctrine/orm: ^3.0
- symfony/deprecation-contracts: ^3.5
- symfony/form: ^5.4|^6.4|^7.4|^8.0
- symfony/framework-bundle: ^5.4|^6.4|^7.4|^8.0
- symfony/http-foundation: ^5.4|^6.4|^7.4|^8.0
- symfony/routing: ^5.4|^6.4|^7.4|^8.0
Requires (Dev)
- doctrine/annotations: ^2.0
- doctrine/doctrine-bundle: ^1.8 || ^2.0 || ^3.0
- rector/rector: ^2.0
- symfony/phpunit-bridge: ^5.4|^6.4|^7.4|^8.0
- symfony/security-csrf: ^5.4|^6.4|^7.4|^8.0
- symfony/var-dumper: ^5.4|^6.4|^7.4|^8.0
- symfony/var-exporter: ^5.4|^6.4|^7.4
- symfony/web-profiler-bundle: ^5.4|^6.4|^7.4|^8.0
- symfony/yaml: ^5.4|^6.4|^7.4|^8.0
- symplify/easy-coding-standard: ^12.5
- twig/twig: ^3.0
Suggests
- symfony/web-profiler-bundle: To inspect in the web debug toolbar which form field produced which DQL condition
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v12.3.0
- v12.2.0
- v12.1.0
- v12.0.1
- v12.0.0
- v11.1.2
- v11.1.1
- v11.1.0
- v11.0.7
- v11.0.6
- v11.0.5
- v11.0.4
- v11.0.3
- v11.0.2
- v11.0.1
- v11.0.0
- v10.0.2
- v10.0.1
- 10.0.0.x-dev
- v10.0.0
- v9.0.2
- v9.0.1
- v9.0.0
- v8.0.1
- v7.0.3
- v7.0.2
- v7.0.1
- v7.0.0
- v6.1.2
- v6.1.1
- v6.1.0
- v6.0.5
- v6.0.4
- v6.0.3
- v6.0.2
- v6.0.1
- v5.0.10
- v5.0.9
- v5.0.8
- v5.0.7
- v5.0.6
- v5.0.5
- v5.0.4
- v5.0.3
- v5.0.2
- v5.0.1
- v5.0.0
- v4.0.2
- v4.0.1
- v4.0.0
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.1.2
- v2.1.1
- v2.1.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.0
- v0.0.3
- dev-feat/filter-state-persistence
- dev-vitepress_docs
- dev-licence
This package is auto-updated.
Last update: 2026-09-07 09:01:34 UTC
README
Build a Symfony form dedicated to filtering an entity, then let the bundle turn it into Doctrine ORM query builder conditions.
LexikFormFilterBundleis nowSpiriitFormFilterBundle: only the name and the GitHub organization changed, the code remains the same.
📖 Full documentation: spiriitlabs.github.io/form-filter-bundle
The idea is:
- Create a form type extending
Symfony\Component\Form\AbstractType, as usual. - Add fields using the provided filter types (e.g.
TextFilterType::classinstead ofTextType::class). - Call
FilterBuilderUpdaterto build the query from the form instance, then execute it.
Any type works, but filtering on a type other than a XxxFilterType::class requires a
custom listener to apply the filter.
Installation
composer require spiriitlabs/form-filter-bundle
Requires PHP 8.1+ and Symfony 5.4+. For Symfony 2.8/3.4, use the latest v5.* tag.
Use it in two steps
1. Create a filter form
<?php namespace Project\Form\Filter; use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type as Filters; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; class RankFilterType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void { $builder->add('name', Filters\TextFilterType::class); $builder->add('rank', Filters\NumberFilterType::class); } }
2. Apply it to a query builder
class DefaultController extends AbstractController { public function __invoke( Request $request, FormFactoryInterface $formFactory, EntityManagerInterface $em, FilterBuilderUpdater $filterBuilderUpdater, ): Response { $form = $formFactory->create(RankFilterType::class); $form->handleRequest($request); $filterBuilder = $em->getRepository(MyEntity::class)->createQueryBuilder('e'); $filterBuilderUpdater->addFilterConditions($form, $filterBuilder); // now look at the DQL =) dump($filterBuilder->getDql()); return $this->render('testFilter.html.twig', ['form' => $form]); } }
Documentation
- Installation
- Basics
- Configuration
- Provided filter types
- Filter state persistence
- Debugging & profiler
Community support
Please open a question on StackOverflow using the
spiriitformfilterbundle tag, the
official support platform for this bundle. GitHub issues are dedicated to bug reports and feature requests.
Credits
- Spiriit dev@spiriit.com
- All contributors
License
This bundle is under the MIT license. For the whole copyright, see the LICENSE file distributed with this source code.