Skip to content

Commit 57a9869

Browse files
committed
Always propagate form null values to formValues
1 parent 1769640 commit 57a9869

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/LiveComponent/src/ComponentWithFormTrait.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ public function getFormName(): string
126126

127127
public function getFormValues(): array
128128
{
129-
if (null === $this->formValues) {
130-
$this->formValues = $this->extractFormValues($this->getForm());
131-
}
132-
133-
return $this->formValues;
129+
return $this->formValues = $this->extractFormValues($this->getForm(), $this->formValues ?? []);
134130
}
135131

136132
private function submitForm(bool $validateAll = true): void
@@ -161,14 +157,17 @@ private function submitForm(bool $validateAll = true): void
161157
* frontend, and it's meant to equal the raw POST data that would
162158
* be sent if the form were submitted without modification.
163159
*/
164-
private function extractFormValues(FormView $formView): array
160+
private function extractFormValues(FormView $formView, array $values = []): array
165161
{
166-
$values = [];
167162
foreach ($formView->children as $child) {
168163
$name = $child->vars['name'];
169164
if (!($child->vars['expanded'] ?? false) && \count($child->children) > 0) {
170-
$values[$name] = $this->extractFormValues($child);
165+
$values[$name] = $this->extractFormValues($child, $values[$name]);
166+
167+
continue;
168+
}
171169

170+
if (null !== ($values[$name] ?? null)) {
172171
continue;
173172
}
174173

0 commit comments

Comments
 (0)