From fbe49cf84dace65928d70ed5eba281b9e509f951 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 9 Feb 2021 09:50:29 +0100 Subject: [PATCH] forward the label_html option to expanded choice fields --- .../Form/Extension/Core/Type/ChoiceType.php | 1 + .../Extension/Core/Type/ChoiceTypeTest.php | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index f0a2aaa0f1..4abd7ab5fc 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -395,6 +395,7 @@ class ChoiceType extends AbstractType $choiceOpts = [ 'value' => $choiceView->value, 'label' => $choiceView->label, + 'label_html' => $options['label_html'], 'attr' => $choiceView->attr, 'translation_domain' => $options['choice_translation_domain'], 'block_name' => 'entry', diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php index 9c8ae2b7e1..5cb9e8a5ba 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php @@ -392,6 +392,20 @@ class ChoiceTypeTest extends BaseTypeTest } } + public function testExpandedCheckboxesInhertLabelHtmlOption() + { + $form = $this->factory->create(static::TESTED_TYPE, null, [ + 'choices' => $this->choices, + 'expanded' => true, + 'label_html' => true, + 'multiple' => true, + ]); + + foreach ($form as $child) { + $this->assertTrue($child->getConfig()->getOption('label_html')); + } + } + public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired() { $form = $this->factory->create(static::TESTED_TYPE, null, [ @@ -420,6 +434,20 @@ class ChoiceTypeTest extends BaseTypeTest } } + public function testExpandedRadiosInhertLabelHtmlOption() + { + $form = $this->factory->create(static::TESTED_TYPE, null, [ + 'choices' => $this->choices, + 'expanded' => true, + 'label_html' => true, + 'multiple' => false, + ]); + + foreach ($form as $child) { + $this->assertTrue($child->getConfig()->getOption('label_html')); + } + } + public function testSubmitSingleNonExpanded() { $form = $this->factory->create(static::TESTED_TYPE, null, [