diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php index 35e69aa71841..edda95dc2c57 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/email_widget.html.php @@ -2,6 +2,7 @@ attributes() ?> name="escape($name) ?>" value="escape($value) ?>" + maxlength="escape($max_length) ?>" disabled="disabled" required="required" /> \ No newline at end of file diff --git a/src/Symfony/Component/Form/Type/Loader/DefaultTypeLoader.php b/src/Symfony/Component/Form/Type/Loader/DefaultTypeLoader.php index e1c3c281f5a2..3eefa694ea3c 100644 --- a/src/Symfony/Component/Form/Type/Loader/DefaultTypeLoader.php +++ b/src/Symfony/Component/Form/Type/Loader/DefaultTypeLoader.php @@ -32,6 +32,7 @@ public function __construct( new Type\CountryType(), new Type\DateType(), new Type\DateTimeType(), + new Type\EmailType(), new Type\HiddenType(), new Type\IntegerType(), new Type\LanguageType(), diff --git a/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php b/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php index c7e333d79611..781ecdcd2025 100644 --- a/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php +++ b/tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php @@ -603,6 +603,41 @@ public function testDateText() ); } + public function testEmail() + { + $form = $this->factory->create('email', 'na&me', array( + 'property_path' => 'name', + 'data' => 'foo&bar', + )); + + $this->assertWidgetMatchesXpath($form->createView(), array(), +'/input + [@type="email"] + [@name="na&me"] + [@value="foo&bar"] + [not(@maxlength)] +' + ); + } + + public function testEmailWithMaxLength() + { + $form = $this->factory->create('email', 'na&me', array( + 'property_path' => 'name', + 'data' => 'foo&bar', + 'max_length' => 123, + )); + + $this->assertWidgetMatchesXpath($form->createView(), array(), +'/input + [@type="email"] + [@name="na&me"] + [@value="foo&bar"] + [@maxlength="123"] +' + ); + } + public function testFile() { $form = $this->factory->create('file', 'na&me', array('property_path' => 'name'));