From 8c967a672cbe56d07bc47fe29d6b4ba5eda707d2 Mon Sep 17 00:00:00 2001 From: awcodes Date: Fri, 4 Nov 2022 14:55:24 -0400 Subject: [PATCH] Fix: bug in relationship fields --- src/Http/Livewire/QuickCreateMenu.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Http/Livewire/QuickCreateMenu.php b/src/Http/Livewire/QuickCreateMenu.php index d52984a..52c1bac 100644 --- a/src/Http/Livewire/QuickCreateMenu.php +++ b/src/Http/Livewire/QuickCreateMenu.php @@ -2,6 +2,7 @@ namespace FilamentQuickCreate\Http\Livewire; +use Filament\Forms\ComponentContainer; use Filament\Pages\Actions\CreateAction; use Filament\Pages\Page; use Filament\Support\Exceptions\Cancel; @@ -144,6 +145,25 @@ public function mountAction(string $name) ]); } + public function getMountedActionForm(): ?ComponentContainer + { + $action = $this->getMountedAction(); + + if (! $action) { + return null; + } + + if ((! $this->isCachingForms) && $this->hasCachedForm('mountedActionForm')) { + return $this->getCachedForm('mountedActionForm'); + } + + return $this->makeForm() + ->schema($action->getFormSchema()) + ->statePath('mountedActionData') + ->model($action->getModel()) + ->context($this->mountedAction); + } + public function getFilamentResources(): array { $resources = collect(QuickCreateFacade::getResources())