-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] added "choice_label_attr" option and deprecated "choice_attr" as multi-arrays or property path #16834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e5cc7cd
eb658f9
23df93d
0fe7097
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,6 +233,23 @@ Form | |
}, | ||
``` | ||
|
||
* Using `choice_attr` option as a string or a `ProprertyPath` instance will | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
throw an exception. Use a `callable` instead. | ||
|
||
Before: | ||
|
||
```php | ||
'choice_attr' => 'htmlAttributes', | ||
``` | ||
|
||
After: | ||
|
||
```php | ||
'choice_attr' => function ($choice, $value, $index) { | ||
return $choice->getHtmlAttributes(); | ||
}, | ||
``` | ||
|
||
FrameworkBundle | ||
--------------- | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,6 +218,7 @@ public function createView(ChoiceListInterface $list, $preferredChoices = null, | |
@trigger_error('Passing callable strings is deprecated since version 3.1 and PropertyAccessDecorator will treat them as property paths in 4.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); | ||
} | ||
|
||
// Deprecated since 3.3 and to be removed in 4.0 with the condition above | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if it is deprecated, it must trigger a deprecation notice. And why deprecating this feature ? It is not consistent with other properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because of what =I explained in the related issue, it's more consistent IMO to deprecate this behavior rather than supporting it for |
||
if ($attr instanceof PropertyPath) { | ||
$attr = function ($choice) use ($accessor, $attr) { | ||
return $accessor->getValue($choice, $attr); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, thanks!