Skip to content

Commit df64d0c

Browse files
committed
Add choice_multiple to test and fix uninitialized value
1 parent af6b46c commit df64d0c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/LiveComponent/src/ComponentWithFormTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function extractFormValues(FormView $formView, array $values = []): arra
162162
foreach ($formView->children as $child) {
163163
$name = $child->vars['name'];
164164
if (!($child->vars['expanded'] ?? false) && \count($child->children) > 0) {
165-
$values[$name] = $this->extractFormValues($child, $values[$name]);
165+
$values[$name] = $this->extractFormValues($child, $values[$name] ?? []);
166166

167167
continue;
168168
}

src/LiveComponent/tests/Fixture/Component/FormComponent1.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ protected function instantiateForm(): FormInterface
6060
],
6161
'expanded' => true,
6262
])
63+
->add('choice_multiple', ChoiceType::class, [
64+
'choices' => [
65+
'foo' => 1,
66+
'bar' => 2,
67+
],
68+
'expanded' => true,
69+
'multiple' => true,
70+
])
6371
->add('checkbox', CheckboxType::class)
6472
->add('file', FileType::class)
6573
->add('hidden', HiddenType::class)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function testFormValues(): void
3030
'range' => '',
3131
'choice' => '',
3232
'choice_expanded' => '',
33+
'choice_multiple' => [],
3334
'checkbox' => null,
3435
'file' => '',
3536
'hidden' => '',

0 commit comments

Comments
 (0)