Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions reference/forms/types/choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,18 @@ method::
new Category('Cat3'),
new Category('Cat4'),
],
'choice_label' => function($category, $key, $index) {
'choice_label' => function($category, $index, $key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function($category, $key, $value)

/** @var Category $category */
return strtoupper($category->getName());
},
'choice_attr' => function($category, $key, $index) {
'choice_attr' => function($category, $index, $key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function($category, $key, $value)

return ['class' => 'category_'.strtolower($category->getName())];
},

'group_by' => function($category, $key, $index) {
'group_by' => function($category, $index, $key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function($category, $key, $value)

// randomly assign things into 2 groups
return rand(0, 1) == 1 ? 'Group A' : 'Group B';
},
'preferred_choices' => function($category, $key, $index) {
'preferred_choices' => function($category, $index, $key) {
return $category->getName() == 'Cat2' || $category->getName() == 'Cat3';
},
]);
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/options/choice_attr.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If an array, the keys of the ``choices`` array must be used as keys::
'No' => false,
'Maybe' => null,
),
'choice_attr' => function($val, $key, $index) {
'choice_attr' => function($val, $index, $key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function($category, $key, $value)

// adds a class like attending_yes, attending_no, etc
return ['class' => 'attending_'.strtolower($key)];
},
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/options/choice_label.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ more control::
'no' => false,
'maybe' => null,
),
'choice_label' => function ($value, $key, $index) {
'choice_label' => function ($value, $index, $key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function($category, $key, $value)

if ($value == true) {
return 'Definitely!';
}
Expand Down
2 changes: 1 addition & 1 deletion reference/forms/types/options/group_by.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Take the following example::
'1 week' => new \DateTime('+1 week'),
'1 month' => new \DateTime('+1 month')
),
'group_by' => function($val, $key, $index) {
'group_by' => function($val, $index, $key) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function($category, $key, $value)

if ($val <= new \DateTime('+3 days')) {
return 'Soon';
} else {
Expand Down