File tree 7 files changed +143
-0
lines changed
src/Symfony/Component/Form
Tests/Extension/Core/Type
7 files changed +143
-0
lines changed Original file line number Diff line number Diff line change 1
1
CHANGELOG
2
2
=========
3
3
4
+ 5.1.0
5
+ -----
6
+
7
+ * Added default ` inputmode ` attribute to Search, Email and Tel form types.
8
+
4
9
5.0.0
5
10
-----
6
11
Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Form \Extension \Core \Type ;
13
13
14
14
use Symfony \Component \Form \AbstractType ;
15
+ use Symfony \Component \Form \FormInterface ;
16
+ use Symfony \Component \Form \FormView ;
15
17
16
18
class EmailType extends AbstractType
17
19
{
@@ -23,6 +25,14 @@ public function getParent()
23
25
return __NAMESPACE__ .'\TextType ' ;
24
26
}
25
27
28
+ /**
29
+ * {@inheritdoc}
30
+ */
31
+ public function buildView (FormView $ view , FormInterface $ form , array $ options )
32
+ {
33
+ $ view ->vars ['attr ' ]['inputmode ' ] = $ options ['attr ' ]['inputmode ' ] ?? 'email ' ;
34
+ }
35
+
26
36
/**
27
37
* {@inheritdoc}
28
38
*/
Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Form \Extension \Core \Type ;
13
13
14
14
use Symfony \Component \Form \AbstractType ;
15
+ use Symfony \Component \Form \FormInterface ;
16
+ use Symfony \Component \Form \FormView ;
15
17
16
18
class SearchType extends AbstractType
17
19
{
@@ -23,6 +25,14 @@ public function getParent()
23
25
return __NAMESPACE__ .'\TextType ' ;
24
26
}
25
27
28
+ /**
29
+ * {@inheritdoc}
30
+ */
31
+ public function buildView (FormView $ view , FormInterface $ form , array $ options )
32
+ {
33
+ $ view ->vars ['attr ' ]['inputmode ' ] = $ options ['attr ' ]['inputmode ' ] ?? 'search ' ;
34
+ }
35
+
26
36
/**
27
37
* {@inheritdoc}
28
38
*/
Original file line number Diff line number Diff line change 12
12
namespace Symfony \Component \Form \Extension \Core \Type ;
13
13
14
14
use Symfony \Component \Form \AbstractType ;
15
+ use Symfony \Component \Form \FormInterface ;
16
+ use Symfony \Component \Form \FormView ;
15
17
16
18
class TelType extends AbstractType
17
19
{
@@ -23,6 +25,14 @@ public function getParent()
23
25
return TextType::class;
24
26
}
25
27
28
+ /**
29
+ * {@inheritdoc}
30
+ */
31
+ public function buildView (FormView $ view , FormInterface $ form , array $ options )
32
+ {
33
+ $ view ->vars ['attr ' ]['inputmode ' ] = $ options ['attr ' ]['inputmode ' ] ?? 'tel ' ;
34
+ }
35
+
26
36
/**
27
37
* {@inheritdoc}
28
38
*/
Original file line number Diff line number Diff line change
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 \Tests \Extension \Core \Type ;
13
+
14
+ class EmailTypeTest extends BaseTypeTest
15
+ {
16
+ const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\EmailType ' ;
17
+
18
+ public function testDefaultInputmode ()
19
+ {
20
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE );
21
+
22
+ $ this ->assertSame ('email ' , $ form ->createView ()->vars ['attr ' ]['inputmode ' ]);
23
+ }
24
+
25
+ public function testOverwrittenInputmode ()
26
+ {
27
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , ['attr ' => ['inputmode ' => 'text ' ]]);
28
+
29
+ $ this ->assertSame ('text ' , $ form ->createView ()->vars ['attr ' ]['inputmode ' ]);
30
+ }
31
+
32
+ public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
33
+ {
34
+ parent ::testSubmitNull ($ expected , $ norm , '' );
35
+ }
36
+ }
Original file line number Diff line number Diff line change
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 \Tests \Extension \Core \Type ;
13
+
14
+ class SearchTypeTest extends BaseTypeTest
15
+ {
16
+ const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\SearchType ' ;
17
+
18
+ public function testDefaultInputmode ()
19
+ {
20
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE );
21
+
22
+ $ this ->assertSame ('search ' , $ form ->createView ()->vars ['attr ' ]['inputmode ' ]);
23
+ }
24
+
25
+ public function testOverwrittenInputmode ()
26
+ {
27
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , ['attr ' => ['inputmode ' => 'text ' ]]);
28
+
29
+ $ this ->assertSame ('text ' , $ form ->createView ()->vars ['attr ' ]['inputmode ' ]);
30
+ }
31
+
32
+ public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
33
+ {
34
+ parent ::testSubmitNull ($ expected , $ norm , '' );
35
+ }
36
+ }
Original file line number Diff line number Diff line change
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 \Tests \Extension \Core \Type ;
13
+
14
+ class TelTypeTest extends BaseTypeTest
15
+ {
16
+ const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\TelType ' ;
17
+
18
+ public function testDefaultInputmode ()
19
+ {
20
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE );
21
+
22
+ $ this ->assertSame ('tel ' , $ form ->createView ()->vars ['attr ' ]['inputmode ' ]);
23
+ }
24
+
25
+ public function testOverwrittenInputmode ()
26
+ {
27
+ $ form = $ this ->factory ->create (static ::TESTED_TYPE , null , ['attr ' => ['inputmode ' => 'text ' ]]);
28
+
29
+ $ this ->assertSame ('text ' , $ form ->createView ()->vars ['attr ' ]['inputmode ' ]);
30
+ }
31
+
32
+ public function testSubmitNull ($ expected = null , $ norm = null , $ view = null )
33
+ {
34
+ parent ::testSubmitNull ($ expected , $ norm , '' );
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments