File tree Expand file tree Collapse file tree 5 files changed +19
-17
lines changed
Bundle/FrameworkBundle/Templating/Helper Expand file tree Collapse file tree 5 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -80,8 +80,16 @@ public function getFilters()
80
80
{
81
81
return array (
82
82
'humanize ' => new \Twig_Filter_Method ($ this , 'renderer->humanize ' ),
83
- 'is_choice_group ' => new \Twig_Filter_Function ('is_array ' , array ('is_safe ' => array ('html ' ))),
84
- 'is_choice_selected ' => new \Twig_Filter_Method ($ this , 'isChoiceSelected ' ),
83
+ );
84
+ }
85
+
86
+ /**
87
+ * {@inheritdoc}
88
+ */
89
+ public function getTests ()
90
+ {
91
+ return array (
92
+ 'selectedchoice ' => new \Twig_Test_Method ($ this , 'isSelectedChoice ' ),
85
93
);
86
94
}
87
95
@@ -108,7 +116,7 @@ public function getFilters()
108
116
*
109
117
* @see ChoiceView::isSelected()
110
118
*/
111
- public function isChoiceSelected (ChoiceView $ choice , $ selectedValue )
119
+ public function isSelectedChoice (ChoiceView $ choice , $ selectedValue )
112
120
{
113
121
if (is_array ($ selectedValue )) {
114
122
return false !== array_search ($ choice ->value , $ selectedValue , true );
Original file line number Diff line number Diff line change 87
87
{% block choice_widget_options %}
88
88
{% spaceless %}
89
89
{% for group_label , choice in options %}
90
- {% if choice | is_choice_group %}
90
+ {% if choice is iterable %}
91
91
<optgroup label =" {{ group_label | trans({}, translation_domain ) }}" >
92
92
{% set options = choice %}
93
93
{{ block (' choice_widget_options' ) }}
94
94
</optgroup >
95
95
{% else %}
96
- <option value =" {{ choice .value }}" {% if choice | is_choice_selected (value ) %} selected =" selected" {% endif %}>{{ choice .label | trans({}, translation_domain ) }}</option >
96
+ <option value =" {{ choice .value }}" {% if choice is selectedchoice (value ) %} selected =" selected" {% endif %}>{{ choice .label | trans({}, translation_domain ) }}</option >
97
97
{% endif %}
98
98
{% endfor %}
99
99
{% endspaceless %}
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ public function testThemeBlockInheritanceUsingExtend()
106
106
);
107
107
}
108
108
109
- public function isChoiceSelectedProvider ()
109
+ public function isSelectedChoiceProvider ()
110
110
{
111
111
// The commented cases should not be necessary anymore, because the
112
112
// choice lists should assure that both values passed here are always
@@ -130,13 +130,13 @@ public function isChoiceSelectedProvider()
130
130
}
131
131
132
132
/**
133
- * @dataProvider isChoiceSelectedProvider
133
+ * @dataProvider isSelectedChoiceProvider
134
134
*/
135
135
public function testIsChoiceSelected ($ expected , $ choice , $ value )
136
136
{
137
137
$ choice = new ChoiceView ($ choice , $ choice . ' label ' );
138
138
139
- $ this ->assertSame ($ expected , $ this ->extension ->isChoiceSelected ($ choice , $ value ));
139
+ $ this ->assertSame ($ expected , $ this ->extension ->isSelectedChoice ($ choice , $ value ));
140
140
}
141
141
142
142
protected function renderEnctype (FormView $ view )
Original file line number Diff line number Diff line change @@ -49,11 +49,6 @@ public function getName()
49
49
return 'form ' ;
50
50
}
51
51
52
- public function isChoiceSelected (ChoiceView $ choice , $ selectedValue )
53
- {
54
- return $ this ->renderer ->isChoiceSelected ($ choice , $ selectedValue );
55
- }
56
-
57
52
/**
58
53
* Sets a theme for a given view.
59
54
*
Original file line number Diff line number Diff line change @@ -113,10 +113,9 @@ CHANGELOG
113
113
* deprecated the methods ` getDefaultOptions ` and ` getAllowedOptionValues `
114
114
in FormTypeInterface and FormTypeExtensionInterface
115
115
* options passed during construction can now be accessed from FormConfigInterface
116
- * added FormBuilderInterface, FormView and FormConfigEditorInterface
117
- * [ BC BREAK] the methods in FormTypeInterface and FormTypeExtensionInterface now
118
- receive FormBuilderInterface and FormView instead of FormBuilder and
119
- FormView
116
+ * added FormBuilderInterface and FormConfigEditorInterface
117
+ * [ BC BREAK] the method ` buildForm ` in FormTypeInterface and FormTypeExtensionInterface
118
+ now receives a FormBuilderInterface instead of a FormBuilder instance
120
119
* [ BC BREAK] the method ` buildViewBottomUp ` was renamed to ` finishView ` in
121
120
FormTypeInterface and FormTypeExtensionInterface
122
121
* [ BC BREAK] the options array is now passed as last argument of the
You can’t perform that action at this time.
0 commit comments