Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4c52265

Browse filesBrowse files
committed
minor #9835 Fixed the params in ChoiceType methods (javiereguiluz)
This PR was squashed before being merged into the 2.8 branch (closes #9835). Discussion ---------- Fixed the params in ChoiceType methods This finishes #9173. Commits ------- b14cf70 Fixed the params in ChoiceType methods
2 parents 81fcfb2 + b14cf70 commit 4c52265
Copy full SHA for 4c52265

File tree

Expand file treeCollapse file tree

4 files changed

+10
-10
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+10
-10
lines changed

‎reference/forms/types/choice.rst

Copy file name to clipboardExpand all lines: reference/forms/types/choice.rst
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,18 @@ method::
107107
new Category('Cat4'),
108108
],
109109
'choices_as_values' => true,
110-
'choice_label' => function($category, $key, $index) {
110+
'choice_label' => function($category, $key, $value) {
111111
/** @var Category $category */
112112
return strtoupper($category->getName());
113113
},
114-
'choice_attr' => function($category, $key, $index) {
114+
'choice_attr' => function($category, $key, $value) {
115115
return ['class' => 'category_'.strtolower($category->getName())];
116116
},
117-
118-
'group_by' => function($category, $key, $index) {
117+
'group_by' => function($category, $key, $value) {
119118
// randomly assign things into 2 groups
120119
return rand(0, 1) == 1 ? 'Group A' : 'Group B';
121120
},
122-
'preferred_choices' => function($category, $key, $index) {
121+
'preferred_choices' => function($category, $key, $value) {
123122
return $category->getName() == 'Cat2' || $category->getName() == 'Cat3';
124123
},
125124
]);

‎reference/forms/types/options/choice_attr.rst.inc

Copy file name to clipboardExpand all lines: reference/forms/types/options/choice_attr.rst.inc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ If an array, the keys of the ``choices`` array must be used as keys::
2323
'Maybe' => null,
2424
),
2525
'choices_as_values' => true,
26-
'choice_attr' => function($val, $key, $index) {
26+
'choice_attr' => function($choiceValue, $key, $value) {
2727
// adds a class like attending_yes, attending_no, etc
2828
return ['class' => 'attending_'.strtolower($key)];
2929
},

‎reference/forms/types/options/choice_label.rst.inc

Copy file name to clipboardExpand all lines: reference/forms/types/options/choice_label.rst.inc
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ more control::
2020
'maybe' => null,
2121
),
2222
'choices_as_values' => true,
23-
'choice_label' => function ($value, $key, $index) {
24-
if ($value == true) {
23+
'choice_label' => function ($choiceValue, $key, $value) {
24+
if (true === $choiceValue) {
2525
return 'Definitely!';
2626
}
27+
2728
return strtoupper($key);
2829

2930
// or if you want to translate some key

‎reference/forms/types/options/group_by.rst.inc

Copy file name to clipboardExpand all lines: reference/forms/types/options/group_by.rst.inc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Take the following example::
2626
'1 month' => new \DateTime('+1 month'),
2727
),
2828
'choices_as_values' => true,
29-
'group_by' => function($value, $key, $index) {
30-
if ($value <= new \DateTime('+3 days')) {
29+
'group_by' => function($choiceValue, $key, $value) {
30+
if ($choiceValue <= new \DateTime('+3 days')) {
3131
return 'Soon';
3232
} else {
3333
return 'Later';

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.