Skip to content

Commit

Permalink
[LiveComponent] Check if accessed vars exist
Browse files Browse the repository at this point in the history
  • Loading branch information
maciazek committed Jan 7, 2025
1 parent 8fcac2a commit 371b971
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/LiveComponent/src/ComponentWithFormTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,13 @@ private function extractFormValues(FormView $formView): array
continue;
}

if (\array_key_exists('choices', $child->vars)
if (\array_key_exists('choices', $child->vars) && $child->vars['choices']
&& $child->vars['required']
&& !$child->vars['disabled']
&& !$child->vars['value']
&& (false === $child->vars['placeholder'] || null === $child->vars['placeholder'])
&& !$child->vars['multiple']
&& !$child->vars['expanded']
&& $child->vars['choices']
&& \array_key_exists('placeholder', $child->vars) && (false === $child->vars['placeholder'] || null === $child->vars['placeholder'])
&& \array_key_exists('multiple', $child->vars) && !$child->vars['multiple']
&& \array_key_exists('expanded', $child->vars) && !$child->vars['expanded']
) {
if (null !== $firstKey = array_key_first($child->vars['choices'])) {
$values[$name] = $child->vars['choices'][$firstKey]->value ?? null;
Expand Down

0 comments on commit 371b971

Please sign in to comment.