Skip to content

Commit df23f98

Browse files
committed
Fix form values for ChoiceType with expanded: true
1 parent a95efba commit df23f98

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/LiveComponent/src/ComponentWithFormTrait.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ private function extractFormValues(FormView $formView): array
166166
$values = [];
167167
foreach ($formView->children as $child) {
168168
$name = $child->vars['name'];
169-
if (\count($child->children) > 0) {
169+
if (
170+
(
171+
!array_key_exists('expanded', $child->vars)
172+
|| !$child->vars['expanded']
173+
)
174+
&& \count($child->children) > 0
175+
) {
170176
$values[$name] = $this->extractFormValues($child);
171177

172178
continue;

src/LiveComponent/tests/Unit/Form/ComponentWithFormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testFormValues(): void
3232
'textarea' => '',
3333
'range' => '',
3434
'choice' => '',
35-
'choice_expanded' => null,
35+
'choice_expanded' => '',
3636
'checkbox' => null,
3737
'file' => '',
3838
'hidden' => '',

0 commit comments

Comments
 (0)