Skip to content

Commit 3823a0b

Browse files
committed
Add Select2CountryType
1 parent d8d7b8f commit 3823a0b

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* This file is part of the EcommitJavascriptBundle package.
4+
*
5+
* (c) E-commit <contact@e-commit.fr>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
11+
namespace Ecommit\JavascriptBundle\Form\Type\Select2;
12+
13+
class Select2CountryType extends AbstractSelect2Type
14+
{
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function getParent()
19+
{
20+
return 'country';
21+
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function getName()
27+
{
28+
return 'ecommit_javascript_select2country';
29+
}
30+
}

Resources/config/services.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
<tag name="form.type" alias="ecommit_javascript_select2choice" />
6161
</service>
6262

63+
<service id="ecommit_javascript.form.type.select2country" class="Ecommit\JavascriptBundle\Form\Type\Select2\Select2CountryType">
64+
<tag name="form.type" alias="ecommit_javascript_select2country" />
65+
</service>
66+
6367
<service id="ecommit_javascript.overlay.jquery_tools_overlay" class="Ecommit\JavascriptBundle\Overlay\JQueryToolsOverlay">
6468
<argument>%ecommit_javascript.use_bootstrap%</argument>
6569
</service>

Resources/views/Form/select2.html.twig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@
7373
{% endspaceless %}
7474
{% endblock %}
7575

76+
{% block ecommit_javascript_select2country_widget %}
77+
{% spaceless %}
78+
{{ form_widget(form) }}
79+
{{ block('ecommit_javascript_select2_js') }}
80+
{% endspaceless %}
81+
{% endblock %}
82+
7683
{% block ecommit_javascript_select2_js %}
7784
<script type="text/javascript">
7885
$(function () {

0 commit comments

Comments
 (0)