From 371b971353af2785bbd26483ca1b5320ef239db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Maci=C4=85g?= Date: Tue, 7 Jan 2025 21:12:44 +0100 Subject: [PATCH] [LiveComponent] Check if accessed vars exist --- src/LiveComponent/src/ComponentWithFormTrait.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/LiveComponent/src/ComponentWithFormTrait.php b/src/LiveComponent/src/ComponentWithFormTrait.php index c8ab525d495..a8376777c1a 100644 --- a/src/LiveComponent/src/ComponentWithFormTrait.php +++ b/src/LiveComponent/src/ComponentWithFormTrait.php @@ -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;