merged branch MaksSlesarenko/fix-for-choice-widget (PR #6734)
This PR was squashed before being merged into the master branch (closes #6734).
Commits
-------
4d51ec0
Fix for hardcode (#6384) in choice widget
Discussion
----------
Fix for hardcode (#6384) in choice widget
empty_value should not be disabled if field is not required!
#6384
---------------------------------------------------------------------------
by sstok at 2013-01-15T15:51:08Z
You need to revert the file mode changes (100644 → 100755)
---------------------------------------------------------------------------
by MaksSlesarenko at 2013-01-18T16:44:42Z
fixed tests
---------------------------------------------------------------------------
by MaksSlesarenko at 2013-01-21T15:36:59Z
ping @fabpot
---------------------------------------------------------------------------
by fabpot at 2013-01-21T15:58:26Z
ping @bschussek
---------------------------------------------------------------------------
by MaksSlesarenko at 2013-01-23T11:15:37Z
ping @fabpot @bschussek
---------------------------------------------------------------------------
by Tobion at 2013-01-23T12:08:19Z
I think it's good to squash and merge.
---------------------------------------------------------------------------
by fabpot at 2013-01-23T12:16:37Z
Can you rebase and squash before I merge? Thanks.
---------------------------------------------------------------------------
by MaksSlesarenko at 2013-01-23T19:51:36Z
@fabpot done
This commit is contained in:
commit
7c957e3411
2
src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
Normal file → Executable file
2
src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig
Normal file → Executable file
@ -69,7 +69,7 @@
|
||||
{% spaceless %}
|
||||
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
|
||||
{% if empty_value is not none %}
|
||||
<option value="" disabled="disabled"{% if value is empty %} selected="selected"{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
|
||||
<option value=""{% if required %} disabled="disabled"{% if value is empty %} selected="selected"{% endif %}{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
|
||||
{% endif %}
|
||||
{% if preferred_choices|length > 0 %}
|
||||
{% set options = preferred_choices %}
|
||||
|
@ -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="" disabled="disabled"<?php if (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 (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 (count($preferred_choices) > 0): ?>
|
||||
<?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?>
|
||||
<?php if (count($choices) > 0 && null !== $separator): ?>
|
||||
|
@ -524,7 +524,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[@name="name"]
|
||||
[not(@required)]
|
||||
[
|
||||
./option[@value=""][not(@selected)][@disabled][.="[trans]Select&Anything&Not&Me[/trans]"]
|
||||
./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Anything&Not&Me[/trans]"]
|
||||
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
|
||||
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
|
||||
]
|
||||
@ -790,7 +790,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/select
|
||||
[@name="name"]
|
||||
[./option[@value=""][not(@selected)][@disabled][.="[trans]Select&Country[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]]
|
||||
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
|
||||
[count(./option)>201]
|
||||
'
|
||||
@ -852,13 +852,13 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[
|
||||
./select
|
||||
[@id="name_date_month"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_day"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_date_year"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
]
|
||||
/following-sibling::div
|
||||
[@id="name_time"]
|
||||
@ -907,10 +907,10 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[
|
||||
./select
|
||||
[@id="name_time_hour"]
|
||||
[./option[@value=""][not(@selected)][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_time_minute"]
|
||||
[./option[@value=""][not(@selected)][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
]
|
||||
]
|
||||
[count(.//select)=5]
|
||||
@ -1063,13 +1063,13 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[
|
||||
./select
|
||||
[@id="name_month"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_day"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
'
|
||||
@ -1096,7 +1096,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[./option[@value="1"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
'
|
||||
@ -1195,15 +1195,15 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[
|
||||
./select
|
||||
[@id="name_month"]
|
||||
[./option[@value=""][not(@selected)][@disabled][.="[trans][/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
|
||||
[./option[@value="1"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_day"]
|
||||
[./option[@value=""][not(@selected)][@disabled][.="[trans][/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
|
||||
[./option[@value="1"][@selected="selected"]]
|
||||
/following-sibling::select
|
||||
[@id="name_year"]
|
||||
[./option[@value=""][not(@selected)][@disabled][.="[trans][/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
|
||||
[./option[@value="1950"][@selected="selected"]]
|
||||
]
|
||||
[count(./select)=3]
|
||||
@ -1635,11 +1635,11 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[
|
||||
./select
|
||||
[@id="name_hour"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
[count(./option)>24]
|
||||
/following-sibling::select
|
||||
[@id="name_minute"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
[count(./option)>60]
|
||||
]
|
||||
[count(./select)=2]
|
||||
@ -1660,7 +1660,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
[
|
||||
./select
|
||||
[@id="name_hour"]
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
|
||||
[count(./option)>24]
|
||||
/following-sibling::select
|
||||
[@id="name_minute"]
|
||||
@ -1710,7 +1710,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
|
||||
|
||||
$this->assertWidgetMatchesXpath($form->createView(), array(),
|
||||
'/select
|
||||
[./option[@value=""][@selected][@disabled][.="[trans]Select&Timezone[/trans]"]]
|
||||
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]]
|
||||
[count(./optgroup)>10]
|
||||
[count(.//option)>201]
|
||||
'
|
||||
|
Reference in New Issue
Block a user