Autocomplete upload widget and form type for Symfony

1.0.0-alpha2 2018-03-13 15:38 UTC


This package provides:

  • an almost dependency-free autocomplete source API, with a generic controller that should be suitable for most frameworks,

  • a Symfony bundle that brings a form widget, source registration, and the associated controller for autocompleting things into forms.


composer require makinacorpus/autocomplete-bundle

This autocomplete widget works with the select2 library, it is your responsability to ensure the javascript is correctly loaded for it to work.

You also need jQuery installed (sorry, this might change later).

Register the routing.yml file in your app/routing.yml file:

    resource: "@AutocompleteBundle/Resources/config/routing.yml"
    prefix: /

And the associated form theme in your app/config.yml file:

    debug:            "%kernel.debug%"
    strict_variables: false
        # ...
        - "AutocompleteBundle:Form:fields.html.twig"

And it should probably work.


First, implement an MakinaCorpus\AutocompleteBundle\Autocomplete\AutocompleteSourceInterface class, that is meant to reflect the business objects in which to autocomplete.

Then just use the MakinaCorpus\AutocompleteBundle\Form\Type\TextAutocompleteType form type in your own form builders, and set the source class name as the source parameter for the form type.