Skip to content

Commit 5a677a3

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: fix rst link syntax Renamed the values in callback functions of ChoiceType to make them more consistent with eachother and the code.
2 parents c3de93a + 8e17e06 commit 5a677a3

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

contributing/code/pull_requests.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ to ensure a constructive feedback process.
376376
If you think someone fails to keep this advice in mind and you want another
377377
perspective, please join the #contribs channel on `Symfony Slack`_. If you
378378
receive feedback you find abusive please contact the
379-
:doc:`CARE team</contributing/code_of_conduct/care_team.rst>`.
379+
:doc:`CARE team </contributing/code_of_conduct/care_team>`.
380380

381-
The :doc:`core team <contributing/code/core_team>` is responsible for deciding
381+
The :doc:`core team </contributing/code/core_team>` is responsible for deciding
382382
which PR gets merged, so their feedback is the most relevant. So do not feel
383383
pressured to refactor your code immediately when someone provides feedback.
384384

reference/forms/types/choice.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,17 @@ method::
9797
new Category('Cat3'),
9898
new Category('Cat4'),
9999
],
100-
'choice_label' => function($category, $key, $value) {
101-
/** @var Category $category */
100+
'choice_label' => function(Category $category, $key, $value) {
102101
return strtoupper($category->getName());
103102
},
104-
'choice_attr' => function($category, $key, $value) {
103+
'choice_attr' => function(Category $category, $key, $value) {
105104
return ['class' => 'category_'.strtolower($category->getName())];
106105
},
107-
'group_by' => function($category, $key, $value) {
106+
'group_by' => function(Category $category, $key, $value) {
108107
// randomly assign things into 2 groups
109108
return rand(0, 1) == 1 ? 'Group A' : 'Group B';
110109
},
111-
'preferred_choices' => function($category, $key, $value) {
110+
'preferred_choices' => function(Category $category, $key, $value) {
112111
return $category->getName() == 'Cat2' || $category->getName() == 'Cat3';
113112
},
114113
]);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If an array, the keys of the ``choices`` array must be used as keys::
1919
'No' => false,
2020
'Maybe' => null,
2121
],
22-
'choice_attr' => function($choiceValue, $key, $value) {
22+
'choice_attr' => function($choice, $key, $value) {
2323
// adds a class like attending_yes, attending_no, etc
2424
return ['class' => 'attending_'.strtolower($key)];
2525
},

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ more control::
1616
'no' => false,
1717
'maybe' => null,
1818
],
19-
'choice_label' => function ($value, $key, $choiceValue) {
20-
if (true === $value) {
19+
'choice_label' => function ($choice, $key, $value) {
20+
if (true === $choice) {
2121
return 'Definitely!';
2222
}
2323

@@ -28,8 +28,8 @@ more control::
2828
},
2929
]);
3030

31-
This method is called for *each* choice, passing you the ``$value`` and
32-
``$key`` from the choices array (additional ``$choiceValue`` is related to `choice_value`_).
31+
This method is called for *each* choice, passing you the ``$choice`` and
32+
``$key`` from the choices array (additional ``$value`` is related to `choice_value`_).
3333
This will give you:
3434

3535
.. image:: /_images/reference/form/choice-example2.png

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Take the following example::
2222
'1 week' => new \DateTime('+1 week'),
2323
'1 month' => new \DateTime('+1 month'),
2424
],
25-
'group_by' => function($choiceValue, $key, $value) {
26-
if ($choiceValue <= new \DateTime('+3 days')) {
25+
'group_by' => function($choice, $key, $value) {
26+
if ($choice <= new \DateTime('+3 days')) {
2727
return 'Soon';
2828
} else {
2929
return 'Later';

reference/forms/types/options/preferred_choices.rst.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ be especially useful if your values are objects::
3333
'1 week' => new \DateTime('+1 week'),
3434
'1 month' => new \DateTime('+1 month'),
3535
],
36-
'preferred_choices' => function ($value, $key) {
36+
'preferred_choices' => function ($choice, $key, $value) {
3737
// prefer options within 3 days
38-
return $value <= new \DateTime('+3 days');
38+
return $choice <= new \DateTime('+3 days');
3939
},
4040
]);
4141

0 commit comments

Comments
 (0)