8000 minor #17351 [Form] Improve `ChoiceType` CS (HeahDude) · Guikingone/symfony-docs@b83a19a · GitHub
[go: up one dir, main page]

Skip to content

Commit b83a19a

Browse files
committed
minor symfony#17351 [Form] Improve ChoiceType CS (HeahDude)
This PR was merged into the 4.4 branch. Discussion ---------- [Form] Improve `ChoiceType` CS Commits ------- 5e9482b [Form] Improve `ChoiceType` CS
2 parents 46101c7 + 5e9482b commit b83a19a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

reference/forms/types/choice.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ method::
7272
// a callback to return the label for a given choice
7373
// if a placeholder is used, its empty value (null) may be passed but
7474
// its label is defined by its own "placeholder" option
75-
'choice_label' => function(?Category $category) {
75+
'choice_label' => function (?Category $category) {
7676
return $category ? strtoupper($category->getName()) : '';
7777
},
7878
// returns the html attributes for each option input (may be radio/checkbox)
79-
'choice_attr' => function(?Category $category) {
79+
'choice_attr' => function (?Category $category) {
8080
return $category ? ['class' => 'category_'.strtolower($category->getName())] : [];
8181
},
8282
// every option can use a string property path or any callable that get
8383
// passed each choice as argument, but it may not be needed
84-
'group_by' => function() {
84+
'group_by' => function () {
8585
// randomly assign things into 2 groups
8686
return rand(0, 1) == 1 ? 'Group A' : 'Group B';
8787
},
8888
// a callback to return whether a category is preferred
89-
'preferred_choices' => function(?Category $category) {
89+
'preferred_choices' => function (?Category $category) {
9090
return $category && 100 < $category->getArticleCounts();
9191
},
9292
]);
@@ -190,7 +190,7 @@ if you want to take advantage of lazy loading::
190190
// ...
191191

192192
$builder->add('constants', ChoiceType::class, [
193-
'choice_loader' => new CallbackChoiceLoader(function() {
193+
'choice_loader' => new CallbackChoiceLoader(function () {
194194
return StaticClass::getConstants();
195195
}),
196196
]);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ If an array, the keys of the ``choices`` array must be used as keys::
3333
'No' => false,
3434
'Maybe' => null,
3535
],
36-
'choice_attr' => function($choice, $key, $value) {
36+
'choice_attr' => function ($choice, $key, $value) {
3737
// adds a class like attending_yes, attending_no, etc
3838
return ['class' => 'attending_'.strtolower($key)];
3939
},

0 commit comments

Comments
 (0)
0