10000 merged branch MaksSlesarenko/fix-for-choice-widget (PR #6734) · xamado/symfony@7c957e3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c957e3

Browse files
committed
merged branch MaksSlesarenko/fix-for-choice-widget (PR symfony#6734)
This PR was squashed before being merged into the master branch (closes symfony#6734). Commits ------- 4d51ec0 Fix for hardcode (symfony#6384) in choice widget Discussion ---------- Fix for hardcode (symfony#6384) in choice widget empty_value should not be disabled if field is not required! symfony#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
2 parents 78e3da5 + 4d51ec0 commit 7c957e3

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
{% spaceless %}
7070
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
7171
{% if empty_value is not none %}
72-
<option value="" disabled="disabled"{% if value is empty %} selected="selected"{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
72+
<option value=""{% if required %} disabled="disabled"{% if value is empty %} selected="selected"{% endif %}{% endif %}>{{ empty_value|trans({}, translation_domain) }}</option>
7373
{% endif %}
7474
{% if preferred_choices|length > 0 %}
7575
{% set options = preferred_choices %}

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<?php echo $view['form']->block($form, 'widget_attributes') ?>
33
<?php if ($multiple): ?> multiple="multiple"<?php endif ?>
44
>
5-
<?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; ?>
5+
<?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; ?>
66
<?php if (count($preferred_choices) > 0): ?>
77
<?php echo $view['form']->block($form, 'choice_widget_options', array('choices' => $preferred_choices)) ?>
88
<?php if (count($choices) > 0 && null !== $separator): ?>

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public function testSingleChoiceWithNonRequiredEmptyValue()
524524
[@name="name"]
525525
[not(@required)]
526526
[
527-
./option[@value=""][not(@selected)][@disabled][.="[trans]Select&Anything&Not&Me[/trans]"]
527+
./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Anything&Not&Me[/trans]"]
528528
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
529529
/following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
530530
]
@@ -790,7 +790,7 @@ public function testCountryWithEmptyValue()
790790
$this->assertWidgetMatchesXpath($form->createView(), array(),
791791
'/select
792792
[@name="name"]
793-
[./option[@value=""][not(@selected)][@disabled][.="[trans]Select&Country[/trans]"]]
793+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]]
794794
[./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]]
795795
[count(./option)>201]
796796
'
@@ -852,13 +852,13 @@ public function testDateTimeWithEmptyValueGlobal()
852852
[
853853
./select
854854
[@id="name_date_month"]
855-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
855+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
856856
/following-sibling::select
857857
[@id="name_date_day"]
858-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
858+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
859859
/following-sibling::select
860860
[@id="name_date_year"]
861-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
861+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
862862
]
863863
/following-sibling::div
864864
[@id="name_time"]
@@ -907,10 +907,10 @@ public function testDateTimeWithEmptyValueOnTime()
907907
[
908908
./select
909909
[@id="name_time_hour"]
910-
[./option[@value=""][not(@selected)][@disabled][.="[trans]Change&Me[/trans]"]]
910+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
911911
/following-sibling::select
912912
[@id="name_time_minute"]
913-
[./option[@value=""][not(@selected)][@disabled][.="[trans]Change&Me[/trans]"]]
913+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
914914
]
915915
]
916916
[count(.//select)=5]
@@ -1063,13 +1063,13 @@ public function testDateChoiceWithEmptyValueGlobal()
10631063
[
10641064
./select
1 628C 0651065
[@id="name_month"]
1066-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
1066+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
10671067
/following-sibling::select
10681068
[@id="name_day"]
1069-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
1069+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
10701070
/following-sibling::select
10711071
[@id="name_year"]
1072-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
1072+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
10731073
]
10741074
[count(./select)=3]
10751075
'
@@ -1096,7 +1096,7 @@ public function testDateChoiceWithEmptyValueOnYear()
10961096
[./option[@value="1"]]
10971097
/following-sibling::select
10981098
[@id="name_year"]
1099-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
1099+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
11001100
]
11011101
[count(./select)=3]
11021102
'
@@ -1195,15 +1195,15 @@ public function testBirthDayWithEmptyValue()
11951195
[
11961196
./select
11971197
[@id="name_month"]
1198-
[./option[@value=""][not(@selected)][@disabled][.="[trans][/trans]"]]
1198+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
11991199
[./option[@value="1"][@selected="selected"]]
12001200
/following-sibling::select
12011201
[@id="name_day"]
1202-
[./option[@value=""][not(@selected)][@disabled][.="[trans][/trans]"]]
1202+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
12031203
[./option[@value="1"][@selected="selected"]]
12041204
/following-sibling::select
12051205
[@id="name_year"]
1206-
[./option[@value=""][not(@selected)][@disabled][.="[trans][/trans]"]]
1206+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]]
12071207
[./option[@value="1950"][@selected="selected"]]
12081208
]
12091209
[count(./select)=3]
@@ -1635,11 +1635,11 @@ public function testTimeWithEmptyValueGlobal()
16351635
[
16361636
./select
16371637
[@id="name_hour"]
1638-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
1638+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
16391639
[count(./option)>24]
16401640
/following-sibling::select
16411641
[@id="name_minute"]
1642-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
1642+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
16431643
[count(./option)>60]
16441644
]
16451645
[count(./select)=2]
@@ -1660,7 +1660,7 @@ public function testTimeWithEmptyValueOnYear()
16601660
[
16611661
./select
16621662
[@id="name_hour"]
1663-
[./option[@value=""][@selected][@disabled][.="[trans]Change&Me[/trans]"]]
1663+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]]
16641664
[count(./option)>24]
16651665
/following-sibling::select
16661666
[@id="name_minute"]
@@ -1710,7 +1710,7 @@ public function testTimezoneWithEmptyValue()
17101710

17111711
$this->assertWidgetMatchesXpath($form->createView(), array(),
17121712
'/select
1713-
[./option[@value=""][@selected][@disabled][.="[trans]Select&Timezone[/trans]"]]
1713+
[./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]]
17141714
[count(./optgroup)>10]
17151715
[count(.//option)>201]
17161716
'

0 commit comments

Comments
 (0)
0