Skip to content

Commit

Permalink
[Form] Removed the "disabled" attribute from the placeholder option i…
Browse files Browse the repository at this point in the history
…n select fields due to problems with the BlackBerry 10 browser
  • Loading branch information
webmozart committed Aug 1, 2013
1 parent b970d17 commit 97cbb19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Expand Up @@ -69,7 +69,7 @@
{% spaceless %}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{% if empty_value is not none %}
<option value=""{% if required %} disabled="disabled"{% if value is empty %} selected="selected"{% endif %}{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
{% endif %}
{% if preferred_choices|length > 0 %}
{% set options = preferred_choices %}
Expand Down
Expand Up @@ -2,7 +2,7 @@
<?php echo $view['form']->block($form, 'widget_attributes') ?>
<?php if ($multiple): ?> multiple="multiple"<?php endif ?>
>
<?php if (null !== $empty_value): ?><option value=""<?php if ($required):?> disabled="disabled"<?php if (empty($value) && "0" !== $value): ?> selected="selected"<?php endif ?><?php endif?>><?php echo $view->escape($view['translator']->trans($empty_value, array(), $translation_domain)) ?></option><?php endif; ?>
<?php if (null !== $empty_value): ?><option value=""<?php if ($required and empty($value) && "0" !== $value): ?> selected="selected"<?php endif?>><?php echo $view->escape($view['translator']->trans($empty_value, array(), $translation_domain)) ?></option><?php endif; ?>
<?php if (count($preferred_choices) > 0): ?>
<?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?>
<?php if (count($choices) > 0 && null !== $separator): ?>
Expand Down
10 changes: 8 additions & 2 deletions src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
Expand Up @@ -543,12 +543,15 @@ public function testSingleChoiceRequiredWithEmptyValue()
'empty_value' => 'Test&Me'
));

// The "disabled" attribute was removed again due to a bug in the
// BlackBerry 10 browser.
// See https://github.com/symfony/symfony/pull/7678
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/select
[@name="name"]
[@required="required"]
[
./option[@value=""][not(@selected)][@disabled][.="[trans]Test&Me[/trans]"]
./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Test&Me[/trans]"]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
Expand All @@ -566,12 +569,15 @@ public function testSingleChoiceRequiredWithEmptyValueViaView()
'expanded' => false,
));

// The "disabled" attribute was removed again due to a bug in the
// BlackBerry 10 browser.
// See https://github.com/symfony/symfony/pull/7678
$this->assertWidgetMatchesXpath($form->createView(), array('empty_value' => ''),
'/select
[@name="name"]
[@required="required"]
[
./option[@value=""][not(@selected)][@disabled][.="[trans][/trans]"]
./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
]
Expand Down

0 comments on commit 97cbb19

Please sign in to comment.