Skip to content

Commit

Permalink
bug #40137 [Form] forward the label_html option to expanded choice fi…
Browse files Browse the repository at this point in the history
…elds (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
-------

fbe49cf forward the label_html option to expanded choice fields
  • Loading branch information
xabbuh committed Feb 9, 2021
2 parents 7866a0f + fbe49cf commit ec38bab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceV
$choiceOpts = [
'value' => $choiceView->value,
'label' => $choiceView->label,
'label_html' => $options['label_html'],
'attr' => $choiceView->attr,
'translation_domain' => $options['choice_translation_domain'],
'block_name' => 'entry',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,20 @@ public function testExpandedCheckboxesAreNeverRequired()
}
}

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, [
Expand Down Expand Up @@ -420,6 +434,20 @@ public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired()
}
}

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, [
Expand Down

0 comments on commit ec38bab

Please sign in to comment.