mapado / typeaheadjs-bundle
Typeahead-js integration in Symfony form type
Installs: 3 797
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 13
Forks: 0
Open Issues: 0
Requires
- symfony/config: ~2.3
- symfony/dependency-injection: ~2.3
- symfony/form: ~2.3
- symfony/http-kernel: ~2.3
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.