diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php index 45b56881a1c5b..9c440665b9764 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/DefaultChoiceListFactory.php @@ -124,7 +124,7 @@ private static function addChoiceView($choice, $value, $label, $keys, &$index, $ if (null === $label) { // If the labels are null, use the original choice key by default $label = (string) $key; - } elseif (false !== $label) { + } else { // If "choice_label" is set to false and "expanded" is true, the value false // should be passed on to the "label" option of the checkboxes/radio buttons $dynamicLabel = \call_user_func($label, $choice, $key, $value); diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index 2ad0859e880fa..0e2ec721cf3f7 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -312,6 +312,16 @@ public function configureOptions(OptionsResolver $resolver) return $choiceTranslationDomain; }; + $choiceLabelNormalizer = function (Options $options, $choiceLabel) { + if (false === $choiceLabel) { + return function () { + return false; + }; + } + + return $choiceLabel; + }; + $resolver->setDefaults([ 'multiple' => false, 'expanded' => false, @@ -339,6 +349,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setNormalizer('placeholder', $placeholderNormalizer); $resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer); $resolver->setNormalizer('choices_as_values', $choicesAsValuesNormalizer); + $resolver->setNormalizer('choice_label', $choiceLabelNormalizer); $resolver->setAllowedTypes('choices', ['null', 'array', '\Traversable']); $resolver->setAllowedTypes('choice_translation_domain', ['null', 'bool', 'string']); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy