PHPackages                             padam87/form-filter-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. padam87/form-filter-bundle

ActiveSymfony-bundle[Search &amp; Filtering](/categories/search)

padam87/form-filter-bundle
==========================

The simplest way to build search forms in Symfony.

v0.10.0(1mo ago)3637MITPHPPHP ^8.4

Since Mar 29Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Padam87/FormFilterBundle)[ Packagist](https://packagist.org/packages/padam87/form-filter-bundle)[ RSS](/packages/padam87-form-filter-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (8)Versions (23)Used By (0)

FormFilterBundle
================

[](#formfilterbundle)

The simplest way to build search forms in Symfony.

Installation
------------

[](#installation)

`composer require padam87/form-filter-bundle`

Usage
-----

[](#usage)

My goal was to create a simpler, lighter way to build to search forms than what is currently available. No learning curve, just a simple abstraction. The bundle uses built-in form types, with some extra filter types for convenience.

The bundle provides a form type extension, and makes 2 new options available for every type:

- `filter` bool / callable, default: true
- `filter_expr` string, has to be a valid doctrine expr, default: eq

### Build a form

[](#build-a-form)

```
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\OptionsResolver\OptionsResolver;

class UserFilterType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class)
            ->add('email', TextType::class)
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            ->setDefaults(
                [
                    'method' => Request::METHOD_GET,
                    'csrf_protection' => false,
                ]
            )
        ;
    }
}
```

As you can see, the search fields are using the built in `TextType`.

### Controller

[](#controller)

```
$filters = $this->createForm(UserFilterType::class);
$filters->handleRequest($request);

$qb = $em->getRepository(User::class)->createQueryBuilder('alias');

$this->get('padam87_form_filter.filters')->apply($qb, $filters);

// paginate, render template etc.
```

Advanced usage
--------------

[](#advanced-usage)

`filter_expr` - You can change the expression used in the filter, for example in the example above it would nice to use a `like` expression instead of `eq`.

```
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class, ['filter_expr' => 'like'])
            ->add('email', TextType::class, ['filter_expr' => 'like'])
        ;
    }
```

`filter` - The filter option gives you full control over the field's behavior. If a simple expression is not enough, you can use a callback to customize the filter.

```
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', TextType::class, ['filter_expr' => 'like'])
            ->add('email', TextType::class, ['filter_expr' => 'like'])
            ->add(
                'city',
                TextType::class,
                [
                    'filter' => function(QueryBuilder $qb, $alias, $value) {
                        $qb
                            //->join('u.address', 'a')
                            ->andWhere($qb->expr->eq('a.city', ':city'))
                            ->setParameter('city', $value)
                        ;

                        return $qb;
                    }
                ]
            )
        ;
    }
```

NOTE: You should not use joins here, write a custom method in the repository, eg `getListQb` and join everything you need to filter there.

### Filter types

[](#filter-types)

- [BooleanFilterType](https://github.com/Padam87/FormFilterBundle/blob/master/Form/BooleanFilterType.php) - 3 state filter for boolean values. (A simple checkbox would only have 2 states).
- [RangeFilterType](https://github.com/Padam87/FormFilterBundle/blob/master/Form/RangeFilterType.php) - A filter for ranges (numeric, date, any other)

```
$builder
    ->add(
        'createdAt',
        RangeFilterType::class,
        [
            'from_field_type' => DateType::class,
            'from_field_options' => [
                'widget' => 'single_text',
            ],
            'to_field_type' => DateType::class,
            'to_field_options' => [
                'widget' => 'single_text',
            ],
            'to_field_expr' => 'lt'
        ]
    )
;
```

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~173 days

Recently: every ~247 days

Total

18

Last Release

59d ago

PHP version history (4 changes)v0.1PHP ^7.0

v0.7.0PHP ^7.0 || ^8.0

v0.8.0PHP ^8.0

v0.10.0PHP ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/776488?v=4)[Adam Prager](/maintainers/Padam87)[@Padam87](https://github.com/Padam87)

---

Top Contributors

[![Padam87](https://avatars.githubusercontent.com/u/776488?v=4)](https://github.com/Padam87 "Padam87 (32 commits)")

---

Tags

searchsymfonyfilterform

### Embed Badge

![Health badge](/badges/padam87-form-filter-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/padam87-form-filter-bundle/health.svg)](https://phpackages.com/packages/padam87-form-filter-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
