bug #40137 [Form] forward the label_html option to expanded choice fields (xabbuh)

This PR was merged into the 5.2 branch.

Discussion
----------

[Form] forward the label_html option to expanded choice fields

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT
| Doc PR        |

Commits
-------

fbe49cf84d forward the label_html option to expanded choice fields
This commit is contained in:
Christian Flothmann 2021-02-09 15:09:16 +01:00
commit ec38bab34a
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, [