lla / autocomplete-form-bundle
Extend Doctrine's entity form type for autocompletion support via form event and custom entity loader exposed as 'autocomplete' form type
Installs: 149
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- doctrine/doctrine-bundle: ^1.4
- symfony/symfony: ~3.4.0
README
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require lla/autocomplete-form-bundle "~1"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new LLA\AutocompleteFormBundle\LLAAutocompleteFormBundle(), ); // ... } // ... }
Step 3: Use the form type
You can use the form as normal form usage. See FormComponent
<?php // src/AppBundle/Controller/TestController.php // ... class TestController extends Controller { public function indexAction() { // ... $form = $this->createForm('form_name', 'autocomplete', array( 'class' => 'AppBundle:YourEntity', 'max_result' => 10, // Initial options length 'query_builder' => function(EntityRepository $repo) { return $repo->createQueryBuilder(); } ));