Skip to content

Commit a1fb3ea

Browse files
committed
forward the label_html option to expanded choice fields
1 parent 1c198a8 commit a1fb3ea

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

Extension/Core/Type/ChoiceType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceV
395395
$choiceOpts = [
396396
'value' => $choiceView->value,
397397
'label' => $choiceView->label,
398+
'label_html' => $options['label_html'],
398399
'attr' => $choiceView->attr,
399400
'translation_domain' => $options['choice_translation_domain'],
400401
'block_name' => 'entry',

Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,20 @@ public function testExpandedCheckboxesAreNeverRequired()
392392
}
393393
}
394394

395+
public function testExpandedCheckboxesInhertLabelHtmlOption()
396+
{
397+
$form = $this->factory->create(static::TESTED_TYPE, null, [
398+
'choices' => $this->choices,
399+
'expanded' => true,
400+
'label_html' => true,
401+
'multiple' => true,
402+
]);
403+
404+
foreach ($form as $child) {
405+
$this->assertTrue($child->getConfig()->getOption('label_html'));
406+
}
407+
}
408+
395409
public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired()
396410
{
397411
$form = $this->factory->create(static::TESTED_TYPE, null, [
@@ -420,6 +434,20 @@ public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired()
420434
}
421435
}
422436

437+
public function testExpandedRadiosInhertLabelHtmlOption()
438+
{
439+
$form = $this->factory->create(static::TESTED_TYPE, null, [
440+
'choices' => $this->choices,
441+
'expanded' => true,
442+
'label_html' => true,
443+
'multiple' => false,
444+
]);
445+
446+
foreach ($form as $child) {
447+
$this->assertTrue($child->getConfig()->getOption('label_html'));
448+
}
449+
}
450+
423451
public function testSubmitSingleNonExpanded()
424452
{
425453
$form = $this->factory->create(static::TESTED_TYPE, null, [

0 commit comments

Comments
 (0)