Skip to content

Commit bc3b15a

Browse files
committed
Add inputmode attribute on some FormType
1 parent 5c37c1f commit bc3b15a

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/Symfony/Component/Form/Extension/Core/Type/EmailType.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,20 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15+
use Symfony\Component\Form\FormInterface;
16+
use Symfony\Component\Form\FormView;
1517
use Symfony\Component\OptionsResolver\OptionsResolver;
1618

1719
class EmailType extends AbstractType
1820
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function buildView(FormView $view, FormInterface $form, array $options)
25+
{
26+
$view->vars['attr']['inputmode'] = 'email';
27+
}
28+
1929
/**
2030
* {@inheritdoc}
2131
*/

src/Symfony/Component/Form/Extension/Core/Type/NumberType.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public function buildView(FormView $view, FormInterface $form, array $options)
4848
if ($options['html5']) {
4949
$view->vars['type'] = 'number';
5050
}
51+
52+
if ($options['scale'] === 0) {
53+
$view->vars['attr']['inputmode'] = 'numeric';
54+
} else {
55+
$view->vars['attr']['inputmode'] = 'decimal';
56+
}
5157
}
5258

5359
/**

src/Symfony/Component/Form/Extension/Core/Type/SearchType.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,20 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15+
use Symfony\Component\Form\FormInterface;
16+
use Symfony\Component\Form\FormView;
1517
use Symfony\Component\OptionsResolver\OptionsResolver;
1618

1719
class SearchType extends AbstractType
1820
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function buildView(FormView $view, FormInterface $form, array $options)
25+
{
26+
$view->vars['attr']['inputmode'] = 'search';
27+
}
28+
1929
/**
2030
* {@inheritdoc}
2131
*/

src/Symfony/Component/Form/Extension/Core/Type/TelType.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,20 @@
1212
namespace Symfony\Component\Form\Extension\Core\Type;
1313

1414
use Symfony\Component\Form\AbstractType;
15+
use Symfony\Component\Form\FormInterface;
16+
use Symfony\Component\Form\FormView;
1517
use Symfony\Component\OptionsResolver\OptionsResolver;
1618

1719
class TelType extends AbstractType
1820
{
21+
/**
22+
* {@inheritdoc}
23+
*/
24+
public function buildView(FormView $view, FormInterface $form, array $options)
25+
{
26+
$view->vars['attr']['inputmode'] = 'tel';
27+
}
28+
1929
/**
2030
* {@inheritdoc}
2131
*/

0 commit comments

Comments
 (0)