mapado/typeaheadjs-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Typeahead-js integration in Symfony form type

v1.0.1 2015-02-16 14:57 UTC

This package is auto-updated.

Last update: 2023-09-15 20:11:21 UTC


README

This bundle provide typeahead.js form type integration into a Symfony project.

Instalation

Install with composer:

$ composer require mapado/typeaheadjs-bundle

Update your app/AppKernel.php file:

$bundles = array(
    // ...
    new Mapado\TypeaheadJsBundle\MapadoTypeaheadJsBundle(),
);

Update your app/config/config.yml file to provide twig form template:

twig:
    form:
        resources:
            - 'MapadoTypeaheadJsBundle:Form:fields.html.twig'

Use your assets manager to include this file: Resources/public/js/typeahead-form.js

Usage

Usage is very simple:

$builder->add('user', 'typeahead', [ 'url' => $searchUrl ]);

You need to pass the $searchUrl as a parameter.

Ajax response

The response must be a JSON array in the following format:

[
    { "id": 1, "value": "Foo" },
    { "id": 2, "value": "Bar" }
]

Note

This bundle is greatly inspired by Lifo101 typeahead bundle but it does work with the typeahead-js new version of typeahead.

It does not requires bootstrap, and supports a lot less features for now.

Feel free to make a PR or open an issue if you want to add stuff.