From 6d5ad3b289574a4ecd937544e3c64280b3a0ddd7 Mon Sep 17 00:00:00 2001 From: William DURAND Date: Fri, 4 May 2012 20:08:56 +0200 Subject: [PATCH] [Form] Added right HTML types to Datetime/Date/Time types if single_text is true --- .../Component/Form/Extension/Core/Type/DateTimeType.php | 4 ++++ src/Symfony/Component/Form/Extension/Core/Type/DateType.php | 4 ++++ src/Symfony/Component/Form/Extension/Core/Type/TimeType.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index 2308059058b1..e74acb20c9d6 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -124,6 +124,10 @@ public function buildForm(FormBuilder $builder, array $options) public function buildView(FormView $view, FormInterface $form) { $view->set('widget', $form->getAttribute('widget')); + + if ('single_text' === $form->getAttribute('widget')) { + $view->set('type', 'datetime'); + } } /** diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php index 38b23e436ab0..e67a232fec81 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateType.php @@ -142,6 +142,10 @@ public function buildViewBottomUp(FormView $view, FormInterface $form) { $view->set('widget', $form->getAttribute('widget')); + if ('single_text' === $form->getAttribute('widget')) { + $view->set('type', 'date'); + } + if ($view->hasChildren()) { $pattern = $form->getAttribute('formatter')->getPattern(); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php index 42cd7f42e536..7fb9d2bd80e9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/TimeType.php @@ -130,6 +130,10 @@ public function buildView(FormView $view, FormInterface $form) ->set('widget', $form->getAttribute('widget')) ->set('with_seconds', $form->getAttribute('with_seconds')) ; + + if ('single_text' === $form->getAttribute('widget')) { + $view->set('type', 'time'); + } } /**