forward the label_html option to expanded choice fields

This commit is contained in:
Christian Flothmann 2021-02-09 09:50:29 +01:00
parent 7866a0fbd6
commit fbe49cf84d
2 changed files with 29 additions and 0 deletions

View File

@ -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',

View File

@ -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, [