merged branch bschussek/issue8526 (PR #8622)

This PR was merged into the 2.2 branch.

Discussion
----------

[Form] Removed the "disabled" attribute from the placeholder option in select fields due to problems with the BlackBerry 10 browser

| Q             | A
| ------------- | ---
| Bug fix?      | yes (together with #8623)
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #7678 #8478 #8526
| License       | MIT
| Doc PR        | -

Commits
-------

97cbb19 [Form] Removed the "disabled" attribute from the placeholder option in select fields due to problems with the BlackBerry 10 browser
This commit is contained in:
Fabien Potencier 2013-08-02 15:12:51 +02:00
commit e82a44ba99
3 changed files with 10 additions and 4 deletions

View File

@ -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 %}

View File

@ -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): ?>

View File

@ -543,12 +543,15 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
'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]"]
]
@ -566,12 +569,15 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
'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]"]
]