From ede04aa73d754da5cc430f19e036203d0dd9d8de Mon Sep 17 00:00:00 2001 From: Kath Young Date: Sun, 14 Apr 2024 11:56:54 +0930 Subject: [PATCH] FILACMS-17: Fix when related drop down is cleared --- src/Filament/Blocks/RelatedResourceBlock.php | 15 ++++++++----- .../rendered/related-contents.blade.php | 22 +++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/Filament/Blocks/RelatedResourceBlock.php b/src/Filament/Blocks/RelatedResourceBlock.php index db27e03a..b682ca00 100644 --- a/src/Filament/Blocks/RelatedResourceBlock.php +++ b/src/Filament/Blocks/RelatedResourceBlock.php @@ -2,18 +2,18 @@ namespace Portable\FilaCms\Filament\Blocks; -use FilamentTiptapEditor\TiptapBlock; - -use Filament\Forms\Components\TextInput; -use Filament\Forms\Components\Select; +use FilaCms; use Filament\Forms\Components\Group; use Filament\Forms\Components\Repeater; +use Filament\Forms\Components\Select; +use Filament\Forms\Components\TextInput; + use Filament\Forms\Get; use Filament\Forms\Set; -use FilaCms; +use FilamentTiptapEditor\TiptapBlock; use Str; class RelatedResourceBlock extends TiptapBlock @@ -63,7 +63,9 @@ public function getFormSchema(): array ->select('id', 'title') ->where('id', $state) ->first(); - $set('title', $article->title); + if($article) { + $set('title', $article->title); + } }) ->columnSpan(2), TextInput::make('title') @@ -71,6 +73,7 @@ public function getFormSchema(): array ]) ->columns(3) ]) + ->addActionLabel('Add Another') ]) ]) ]; diff --git a/views/filament/blocks/rendered/related-contents.blade.php b/views/filament/blocks/rendered/related-contents.blade.php index e69de29b..6a13bba8 100644 --- a/views/filament/blocks/rendered/related-contents.blade.php +++ b/views/filament/blocks/rendered/related-contents.blade.php @@ -0,0 +1,22 @@ +
+ +
+
+ @foreach ($selectedContents as $key => $item) + + @endforeach +
+
+