Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

Latest commit

 

History

History
46 lines (37 loc) · 1.17 KB

File metadata and controls

46 lines (37 loc) · 1.17 KB

jQuery Select2 Field (view demo)

Enable it in your app configuration :

# app/config/config.yml
sh_form:
    select2: ~

Download the plugin and include its assets : http://ivaynberg.github.com/select2/

Default Usage:

You can use all the core choice types from Symfony (choice, country, ...) and Doctrine (ORM and ODM), you just have to prefix the type name with genemu_jqueryselect2_* :

<?php
// ...
public function buildForm(FormBuilder $builder, array $options)
{
    $builder
        // ...
        ->add('choice', 'genemu_jqueryselect2_choice', array(
            'choices' => array(
                'foo' => 'Foo',
                'bar' => 'Bar',
            )
        ))
        ->add('country', 'genemu_jqueryselect2_country')
        ->add('entity', 'genemu_jqueryselect2_entity', array(
            'class' => 'MyBundle\Entity\Class',
            'property' => 'name',
        ))
    ;
}

For more information on options available for each type, cf. to this form type documentation.

Extra

  1. Ajax
  2. Configuration example