Skip to content

Commit

Permalink
[Form] improve deprecation messages for the "empty_value" and "choice…
Browse files Browse the repository at this point in the history
…_list" options in the ChoiceType class.
  • Loading branch information
Hugo Hamon committed Dec 29, 2015
1 parent a63dd19 commit 7878536
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Expand Up @@ -292,9 +292,10 @@ public function configureOptions(OptionsResolver $resolver)
return;
};

$choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory) {
$that = $this;
$choiceListNormalizer = function (Options $options, $choiceList) use ($choiceListFactory, $that) {
if ($choiceList) {
@trigger_error('The "choice_list" option is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', E_USER_DEPRECATED);
@trigger_error(sprintf('The "choice_list" option of the "%s" form type (%s) is deprecated since version 2.7 and will be removed in 3.0. Use "choice_loader" instead.', $that->getName(), __CLASS__), E_USER_DEPRECATED);

if ($choiceList instanceof LegacyChoiceListInterface) {
return new LegacyChoiceListAdapter($choiceList);
Expand All @@ -321,9 +322,9 @@ public function configureOptions(OptionsResolver $resolver)
return $choiceListFactory->createListFromChoices($choices, $options['choice_value']);
};

$placeholderNormalizer = function (Options $options, $placeholder) {
$placeholderNormalizer = function (Options $options, $placeholder) use ($that) {
if (!is_object($options['empty_value']) || !$options['empty_value'] instanceof \Exception) {
@trigger_error('The form option "empty_value" is deprecated since version 2.6 and will be removed in 3.0. Use "placeholder" instead.', E_USER_DEPRECATED);
@trigger_error(sprintf('The form option "empty_value" of the "%s" form type (%s) is deprecated since version 2.6 and will be removed in 3.0. Use "placeholder" instead.', $that->getName(), __CLASS__), E_USER_DEPRECATED);

$placeholder = $options['empty_value'];
}
Expand Down

0 comments on commit 7878536

Please sign in to comment.