spiriitlabs / form-filter-bundle
This bundle aim to provide classes to build some form filters and then build a doctrine query from this form filter.
Installs: 179 092
Dependents: 6
Suggesters: 1
Security: 0
Stars: 23
Watchers: 2
Forks: 13
Type:symfony-bundle
Requires
- php: ^8.1
- doctrine/dbal: ^3.0
- doctrine/orm: ^3.0
- symfony/form: ^5.4|^6.4|^7.0
- symfony/framework-bundle: ^5.4|^6.4|^7.0
Requires (Dev)
- doctrine/annotations: ^2.0
- doctrine/doctrine-bundle: ^1.8 || ^2.0
- rector/rector: ^0.17.1
- symfony/phpunit-bridge: ^5.4|^6.4|^7.0
- symfony/var-dumper: ^5.4|^6.4|^7.0
- symplify/easy-coding-standard: ^11.3
- dev-master
- 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-licence
This package is auto-updated.
Last update: 2024-11-22 10:50:37 UTC
README
The LexikFormFilterBundle, a historical bundle, is now renamed to SpiriitFormFilterBundle. The code remains unchanged; only the name and organization have changed on GitHub.
This Symfony bundle aims to provide classes to build some form types dedicated to filter an entity. Once you created your form type you will be able to update a doctrine query builder conditions from a form type.
The idea is:
- Create a form type extending from
Symfony\Component\Form\AbstractType
as usual. - Add form fields by using provided filter types (e.g. use TextFilterType::class instead of a TextType::class type) (*).
- Then call a service to build the query from the form instance and execute your query to get your result :).
(*): In fact you can use any type, but if you want to apply a filter by not using a XxxFilterType::class type you will have to create a custom listener class to apply the filter for this type.
Installation
================
The bundle can be installed using Composer or the Symfony binary:
composer require spiriitlabs/form-filter-bundle
Use it in two steps
create a form
<?php namespace Project\Form\Filter; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Spiriit\Bundle\FormFilterBundle\Filter\Form\Type as Filters; class RankFilterType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('name', Filters\TextFilterType::class); $builder->add('rank', Filters\NumberFilterType::class); } }
use it in your controller
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
This Symfony bundle is compatible with Symfony 4.3 or higher.
For Symfony 2.8/3.4 please use tags v5.*
For installation and how to use the bundle refer to Resources/doc/index.md
- Installation
- Configuration
- Provided form types
- Example & inner workings
- Working with the filters
- The FilterTypeExtension
- Working with other bundles
- Real use case - Advanced usage with PagerFanta
Community Support
Please consider opening a question on StackOverflow using the spiriitformfilterbundle
tag, it is the official support platform for this bundle.
Github Issues are dedicated to bug reports and feature requests.
For compatibility with Symfony 2.8 and 3.4
Please use last tag v5.*
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.