8000 Implemented: [Form] Add "range" type #11979 · crevillo/symfony@feb9257 · GitHub
[go: up one dir, main page]

Skip to content

Commit feb9257

Browse files
committed
Implemented: [Form] Add "range" type symfony#11979
1 parent d277c16 commit feb9257

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@
141141
{{- block('form_widget_simple') -}}
142142
{%- endblock integer_widget %}
143143

144+
{% block range_widget -%}
145+
{% set type = type|default('range') %}
146+
{{- block('form_widget_simple') -}}
147+
{%- endblock range_widget %}
148+
144149
{% block money_widget -%}
145150
{{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
146151
{%- endblock money_widget %}

src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@
146146
<service id="form.type.currency" class="Symfony\Component\Form\Extension\Core\Type\CurrencyType">
147147
<tag name="form.type" alias="currency" />
148148
</service>
149+
<service id="form.type.range" class="Symfony\Component\Form\Extension\Core\Type\RangeType">
150+
<tag name="form.type" alias="range" />
151+
</service>
149152

150153
<!-- FormTypeHttpFoundationExtension -->
151154
<service id="form.type_extension.form.http_foundation" class="Symfony\Component\Form\Extension\HttpFoundation\Type\FormTypeHttpFoundationExtension">
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Form\Extension\Core\Type;
13+
14+
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
15+
use Symfony\Component\Form\AbstractType;
16+
17+
/**
18+
* A range form element.
19+
*
20+
* @author Carlos Revillo <crevillo@gmail.com>
21+
*/
22+
class RangeType extends AbstractType
23+
{
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function setDefaultOptions(OptionsResolverInterface $resolver)
28+
{
29+
$resolver->setDefaults(array(
30+
'min' => null,
31+
'max' => null,
32+
));
33+
}
34+
35+
/**
36+
* {@inheritdoc}
37+
*/
38+
public function getParent()
39+
{
40+
return 'integer';
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function getName()
47+
{
48+
return 'range';
49+
}
50+
}

0 commit comments

Comments
 (0)
0