Skip to content

Commit

Permalink
[Form] Added right HTML types to Datetime/Date/Time types if single_t…
Browse files Browse the repository at this point in the history
…ext is true
  • Loading branch information
willdurand committed May 12, 2012
1 parent e193452 commit 6d5ad3b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Expand Up @@ -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');
}
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Expand Up @@ -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();

Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Component/Form/Extension/Core/Type/TimeType.php
Expand Up @@ -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');
}
}

/**
Expand Down

0 comments on commit 6d5ad3b

Please sign in to comment.