Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ec38bab

Browse filesBrowse files
committed
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 ------- fbe49cf forward the label_html option to expanded choice fields
2 parents 7866a0f + fbe49cf commit ec38bab
Copy full SHA for ec38bab

File tree

Expand file treeCollapse file tree

2 files changed

+29
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+29
-0
lines changed

‎src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+1Lines 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',

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
+28Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.