From dd90b50109f364ca565feb5836597bc91acf9475 Mon Sep 17 00:00:00 2001 From: Abdulmajeed-Jamaan <41128358+Abdulmajeed-Jamaan@users.noreply.github.com> Date: Wed, 15 Oct 2025 00:15:45 +0300 Subject: [PATCH] fix: context handling in EditForm field actions Updated the context passed to mountAction for field options to only include 'recordKey' if the section has an 'id' key. This prevents potential errors when 'id' is missing from the section array. --- src/Filament/Resources/FormResource/Pages/EditForm.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Filament/Resources/FormResource/Pages/EditForm.php b/src/Filament/Resources/FormResource/Pages/EditForm.php index 4666e33a..7ac9f0de 100644 --- a/src/Filament/Resources/FormResource/Pages/EditForm.php +++ b/src/Filament/Resources/FormResource/Pages/EditForm.php @@ -60,7 +60,13 @@ protected function beforeValidate(): void foreach ($formSections as $sectionId => $section) { foreach ($section['fields'] as $fieldId => $field) { - $this->mountAction('fields options', ['item' => $fieldId], ['recordKey' => $section['id'], 'schemaComponent' => "form.sections.$sectionId.fields"]); + $context = ['schemaComponent' => "form.sections.$sectionId.fields"]; + + if (array_key_exists('id', $section)) { + $context['recordKey'] = $section['id']; + } + + $this->mountAction('fields options', ['item' => $fieldId], context: $context); $this->callMountedAction(); $this->unmountAction(); }