PHPackages                             docdigital/filter-type-guesser - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. docdigital/filter-type-guesser

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

docdigital/filter-type-guesser
==============================

Integrates Lexik Filter types with FormTypes generated by generator-bundle

22181[1 issues](https://github.com/juanmf/FilterTypeGuesserBundle/issues)PHP

Since Mar 1Pushed 10y ago2 watchersCompare

[ Source](https://github.com/juanmf/FilterTypeGuesserBundle)[ Packagist](https://packagist.org/packages/docdigital/filter-type-guesser)[ RSS](/packages/docdigital-filter-type-guesser/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Overview
========

[](#overview)

This Symfony2 Bundle Integrates Lexik Filter types with FormTypes generated by Sensio generator-bundle or any AbstractType that relies on Dcotrine ORM's Type Guessing (i.e. don't assign hardcoded type to its form fields.)

It works by changing Doctrine GuessedTypes for the lexikFormFilter best filter\_type fit in the given form.

Instalation
===========

[](#instalation)

Update your composer.json

```
    "require": {
        ...
        "docdigital/filter-type-guesser": "dev-master"
    },
    ...
```

Then run the composer update command in your project root dir

```
$ php composer.phar update docdigital/filter-type-guesser

```

After composer finish, register the Bundel in app/appKernel.php

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
            new DocDigital\Bundle\FilterTypeGuesserBundle\DdFilterTypeGuesserBundle(),
        );
        ...
        return $bundles;
    }
    ...
}
```

Usage
=====

[](#usage)

In your Controller add a method like this, to create the FilterForm, out of the regular Entity's FormType.

```
    /**
     * Creates a Filter form to search for Entities.
     *
     * @param AbstractType|string $formType The `generate:doctrine:form` generated Type or its FQCN.
     *
     * @return \Symfony\Component\Form\Form The filter Form
     */
    private function createFilterForm($formType)
    {
        $adapter = $this->get('dd_form.form_adapter');
        $form = $adapter->adaptForm(
            $formType,
            $this->generateUrl('document_search'),
            array('fieldToRemove1', 'fieldToRemove2')
        );
        return $form;
    }
```

Then, the query building process is [lexik's](https://github.com/lexik/LexikFormFilterBundle/blob/master/Resources/doc/index.md#simple-example)

```
    /**
     * Collects filterForm filled params and builds a Query.
     *
     * @Route("/find", name="document_search")
     * @Method("POST")
     * @template("DdDocumentBundle:Document:index.html.twig")
     */
    public function searchAction(Request $request)
    {
        // $docType = new FormType/FQCN() could do too.
        $docType = 'FormType/FQCN';
        $filterForm = $this->createFilterForm($docType);
        $filterForm->handleRequest($request);

        $filterBuilder = $this->getDocRepo($docType)
            ->createQueryBuilder('e');
        $this->get('lexik_form_filter.query_builder_updater')
            ->addFilterConditions($filterForm, $filterBuilder);

        $entities = $filterBuilder->getQuery()->execute();

        return array(
            'entities'   => $entities,
            'filterForm' => $filterForm->createView(),
        );
    }
```

Events for changing the default filterTypes
===========================================

[](#events-for-changing-the-default-filtertypes)

New since commit 2689659a6109b512c786ab6472fcc7eaa1c72a7b

```
class KernelEvents implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return array(
            'kernel.request' => 'handleRequest',
        );
    }

    public function handleRequest(GetResponseEvent $event)
    {
        /**
         * Adds {@link FilterFormTypeGuesser} overrider to change default filter dates.
         */
        $event->getDispatcher()->addListener(
            FilterFormTypeGuesserEvents::FILTER_TYPE_GUESSER_LOADED,
            array(new TypeGuesserOverriderListener(), 'override')
        );
    }
}

class TypeGuesserOverriderListener
{
   /**
    * Overrides the default filter types associated with some Doctrine Guessed types.
    *
    * This code replaces ugly 3 Selects Date by a Bootstrap Date Time picker implementation.
    *
    * @param FilterFormTypeGuesserEvent $event the event containing the TypesMap.
    * /
   public function override(FilterFormTypeGuesserEvent $event)
   {
       $event->typesMap['date'] = 'dd_filter_date_range';
       $event->typesMap['datetime'] = 'dd_filter_date_range';
       $event->typesMap['time'] = 'dd_filter_date_range';
   }
}
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/886723?v=4)[Juan Manuel Fernandez](/maintainers/juanmf)[@juanmf](https://github.com/juanmf)

---

Top Contributors

[![juanmf](https://avatars.githubusercontent.com/u/886723?v=4)](https://github.com/juanmf "juanmf (7 commits)")

### Embed Badge

![Health badge](/badges/docdigital-filter-type-guesser/health.svg)

```
[![Health](https://phpackages.com/badges/docdigital-filter-type-guesser/health.svg)](https://phpackages.com/packages/docdigital-filter-type-guesser)
```

###  Alternatives

[pixelalbatross/slider-block

132.2k](/packages/pixelalbatross-slider-block)

PHPackages © 2026

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