diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
index 699b2f849535e..47c06b8ab1dd8 100644
--- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
+++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
@@ -175,6 +175,11 @@
{{- block('form_widget_simple') -}}
{%- endblock email_widget %}
+{% block range_widget -%}
+ {% set type = type|default('range') %}
+ {{- block('form_widget_simple') -}}
+{%- endblock range_widget %}
+
{% block button_widget -%}
{% if label is empty -%}
{% set label = name|humanize %}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
index 23d8ec260cafb..b910decba0c9e 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
@@ -113,6 +113,9 @@
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php
new file mode 100644
index 0000000000000..4c628f8e005bc
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/range_widget.html.php
@@ -0,0 +1 @@
+block($form, 'form_widget_simple', array('type' => isset($type) ? $type : 'range'));
diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md
index 4381726126d48..0f92bd48ffb3d 100644
--- a/src/Symfony/Component/Form/CHANGELOG.md
+++ b/src/Symfony/Component/Form/CHANGELOG.md
@@ -6,6 +6,7 @@ CHANGELOG
* added "html5" option to Date, Time and DateTimeFormType to be able to
enable/disable HTML5 input date when widget option is "single_text"
+ * added the html5 "range" FormType
2.5.0
------
diff --git a/src/Symfony/Component/Form/Extension/Core/CoreExtension.php b/src/Symfony/Component/Form/Extension/Core/CoreExtension.php
index a0153a57eb700..940101a905d48 100644
--- a/src/Symfony/Component/Form/Extension/Core/CoreExtension.php
+++ b/src/Symfony/Component/Form/Extension/Core/CoreExtension.php
@@ -42,6 +42,7 @@ protected function loadTypes()
new Type\PasswordType(),
new Type\PercentType(),
new Type\RadioType(),
+ new Type\RangeType(),
new Type\RepeatedType(),
new Type\SearchType(),
new Type\TextareaType(),
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php b/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php
new file mode 100644
index 0000000000000..78909e643f5a7
--- /dev/null
+++ b/src/Symfony/Component/Form/Extension/Core/Type/RangeType.php
@@ -0,0 +1,33 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Form\Extension\Core\Type;
+
+use Symfony\Component\Form\AbstractType;
+
+class RangeType extends AbstractType
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function getParent()
+ {
+ return 'text';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName()
+ {
+ return 'range';
+ }
+}
diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
index 4755e208e9a51..3fb8f9fd0742a 100644
--- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
+++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
@@ -1347,6 +1347,35 @@ public function testLanguage()
);
}
+ public function testRange()
+ {
+ $form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5)));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array(),
+'/input
+ [@type="range"]
+ [@name="name"]
+ [@value=42]
+ [@min=5]
+'
+ );
+ }
+
+ public function testRangeWithMinMaxValues()
+ {
+ $form = $this->factory->createNamed('name', 'range', 42, array('attr' => array('min' => 5, 'max' => 57)));
+
+ $this->assertWidgetMatchesXpath($form->createView(), array(),
+'/input
+ [@type="range"]
+ [@name="name"]
+ [@value=42]
+ [@min=5]
+ [@max=57]
+'
+ );
+ }
+
public function testLocale()
{
$form = $this->factory->createNamed('name', 'locale', 'de_AT');
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy