Skip to content

Commit

Permalink
Added html5 email input to the forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Miha Vrhovnik committed Apr 18, 2011
1 parent 4bb823f commit 50011fa
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml
Expand Up @@ -25,7 +25,7 @@
<service id="form.factory" class="%form.factory.class%">
<argument type="service" id="form.type.loader" />
<!--
All services with tag "form.guesser" are inserted here by
All services with tag "form.guesser" are inserted here by
AddFormGuessersPass
-->
<argument type="collection" />
Expand All @@ -36,7 +36,7 @@
<tag name="form.guesser" />
<argument type="service" id="validator.mapping.class_metadata_factory" />
</service>

<!-- CsrfProvider -->
<service id="form.csrf_provider" class="%form.csrf_provider.class%">
<argument type="service" id="session" />
Expand All @@ -50,17 +50,17 @@
<argument>%file.temporary_storage.nesting_levels%</argument>
<argument>%file.temporary_storage.directory%</argument>
</service>

<!-- ContainerAwareTypeLoader -->
<service id="form.type.loader" class="%form.type.loader.class%">
<argument type="service" id="service_container" />
<!--
All services with tag "form.type" are inserted here by
All services with tag "form.type" are inserted here by
AddFormTypesPass
-->
<argument type="collection" />
</service>

<!-- FieldTypes -->
<service id="form.type.field" class="Symfony\Component\Form\Type\FieldType">
<tag name="form.type" alias="field" />
Expand Down Expand Up @@ -94,6 +94,9 @@
<service id="form.type.datetime" class="Symfony\Component\Form\Type\DateTimeType">
<tag name="form.type" alias="datetime" />
</service>
<service id="form.type.email" class="Symfony\Component\Form\Type\EmailType">
<tag name="form.type" alias="email" />
</service>
<service id="form.type.file" class="Symfony\Component\Form\Type\FileType">
<tag name="form.type" alias="file" />
<argument type="service" id="file.temporary_storage" />
Expand Down Expand Up @@ -143,6 +146,6 @@
<service id="form.type.url" class="Symfony\Component\Form\Type\UrlType">
<tag name="form.type" alias="url" />
</service>

</services>
</container>
@@ -0,0 +1,7 @@
<input type="email"
<?php echo $view['form']->attributes() ?>
name="<?php echo $view->escape($name) ?>"
value="<?php echo $view->escape($value) ?>"
<?php if ($read_only): ?>disabled="disabled"<?php endif ?>
<?php if ($required): ?>required="required"<?php endif ?>
/>
Expand Up @@ -256,3 +256,10 @@
</div>
{% endspaceless %}
{% endblock form__widget %}

{% block email__widget %}
{% spaceless %}
{% set type = type|default('email') %}
{{ block('field__widget') }}
{% endspaceless %}
{% endblock email__widget %}
28 changes: 28 additions & 0 deletions src/Symfony/Component/Form/Type/EmailType.php
@@ -0,0 +1,28 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\Form\Type;

use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormInterface;

class EmailType extends AbstractType
{
public function getParent(array $options)
{
return 'field';
}

public function getName()
{
return 'email';
}
}

0 comments on commit 50011fa

Please sign in to comment.