diff --git a/app/Filament/Components/Fields/BelongsTo.php b/app/Filament/Components/Fields/BelongsTo.php index f485e1fe0..8d5afbefd 100644 --- a/app/Filament/Components/Fields/BelongsTo.php +++ b/app/Filament/Components/Fields/BelongsTo.php @@ -27,8 +27,11 @@ class BelongsTo extends ComponentsSelect */ protected function reload(): void { + $model = $this->resource->getModel(); + if ($this->showCreateOption && $this->resource !== null) { $this->createOptionForm(fn (Form $form) => $this->resource::form($form)->getComponents()); + $this->createOptionUsing(fn (array $data) => (new $model)::query()->create($data)->getKey()); } if ($this->resource) { diff --git a/app/Filament/Resources/Wiki/Anime/Theme.php b/app/Filament/Resources/Wiki/Anime/Theme.php index e3bd87e99..6a10103af 100644 --- a/app/Filament/Resources/Wiki/Anime/Theme.php +++ b/app/Filament/Resources/Wiki/Anime/Theme.php @@ -232,8 +232,7 @@ class Theme extends BaseResource ->resource(ArtistResource::class) ->showCreateOption() ->required() - ->rules(['required']) - ->createOptionUsing(fn (array $data) => Artist::query()->create($data)->getKey()), + ->rules(['required']), TextInput::make(ArtistSong::ATTRIBUTE_AS) ->label(__('filament.fields.artist.songs.as.name'))