diff --git a/Form/Type/Select2ChoiceType.php b/Form/Type/Select2ChoiceType.php
new file mode 100644
index 000000000..47ca93d93
--- /dev/null
+++ b/Form/Type/Select2ChoiceType.php
@@ -0,0 +1,49 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\Form\Type;
+
+use Symfony\Component\Form\AbstractType;
+use Symfony\Component\OptionsResolver\OptionsResolverInterface;
+
+/**
+ * Extends choice to allow adding select2 library on widget
+ *
+ * @author Julien Fastré
+ */
+class Select2ChoiceType extends AbstractType
+{
+ public function getName()
+ {
+ return 'select2_choice';
+ }
+
+ public function getParent()
+ {
+ return 'choice';
+ }
+
+ public function setDefaultOptions(OptionsResolverInterface $resolver)
+ {
+ $resolver->replaceDefaults(
+ array('attr' => array('class' => 'select2 '))
+ );
+ }
+}
diff --git a/Resources/config/services.yml b/Resources/config/services.yml
index 751bf577c..404b8012f 100644
--- a/Resources/config/services.yml
+++ b/Resources/config/services.yml
@@ -25,3 +25,8 @@ services:
- "%locale%"
tags:
- { name: form.type, alias: translatable_string }
+
+ chill.main.form.type.select2choice:
+ class: Chill\MainBundle\Form\Type\Select2ChoiceType
+ tags:
+ - {name: form.type, alias: select2_choice}
diff --git a/Resources/views/layout.html.twig b/Resources/views/layout.html.twig
index 5c0ea4d9b..a11253461 100644
--- a/Resources/views/layout.html.twig
+++ b/Resources/views/layout.html.twig
@@ -134,7 +134,7 @@
}
});
- $('select').select2();
+ $('.select2').select2();