Skip to content

Commit b14cf70

Browse files
committed
Fixed the params in ChoiceType methods
1 parent ac45677 commit b14cf70

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

reference/forms/types/choice.rst

+4-5
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

+1-1
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

+3-2
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

+2-2
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)