-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Deprecate a callable empty_data in ChoiceType #25924
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 all commits
96e194c
b8ac58c
f8cc144
62d2c14
da3c6ac
db28aef
734fce1
3d19d31
6173596
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,14 @@ public function buildForm(FormBuilderInterface $builder, array $options) | |
$emptyData = $form->getConfig()->getEmptyData(); | ||
|
||
if (false === FormUtil::isEmpty($emptyData) && array() !== $emptyData) { | ||
$data = is_callable($emptyData) ? call_user_func($emptyData, $form, $data) : $emptyData; | ||
if (is_callable($emptyData)) { | ||
if (is_string($emptyData)) { | ||
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. I've introduced that change as a bug fix in #17822 targeting 2.7. 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. #17822 is over 1.5y old now. People might have built code against that "feature" already. :-( 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. Also, I would not check for 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. The |
||
@trigger_error('Passing callable strings is deprecated since version 4.1 and will be removed in 5.0. You should use a "\Closure" instead.', E_USER_DEPRECATED); | ||
} | ||
$data = call_user_func($emptyData, $form, $data); | ||
} else { | ||
$data = $emptyData; | ||
} | ||
} | ||
} | ||
|
||
|
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.
Or just
Closure::fromCallable('some_function')
😉