Permalink
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (35 sloc) 1.03 KB

Use JQueryAutocomplete to suggest values on a text field

Minimal configuration:

# app/config/config.yml
genemu_form:
    autocomplete: ~

Usage:

<?php
// ...
public function buildForm(FormBuilder $builder, array $options)
{
    $builder
        // Text suggestions
        ->add('soccer_player', 'genemu_jqueryautocomplete_text', array(
            'suggestions' => array(
                'Ozil',
                'Van Persie'
            ),
        ))
        // Suggestions with doctrine orm
        ->add('soccer_player', 'genemu_jqueryautocomplete_entity', array(
            'class' => 'MyBundle\Entity\MyEntity',
            'property' => 'name',
        ))
        // Suggestions with doctrine odm
        ->add('soccer_player', 'genemu_jqueryautocomplete_document', array(
            'class' => 'MyBundle\Document\MyDocument',
            'property' => 'name',
        ));
}

Extra

Ajax Suggestions