22
33namespace CodeWithDennis \FilamentSelectTree ;
44
5+ use Filament \Schemas \Components \Contracts \HasAffixActions ;
6+ use Filament \Schemas \Components \Concerns \CanBeDisabled ;
7+ use Filament \Schemas \Components \Concerns \HasActions ;
8+ use Filament \Schemas \Schema ;
9+ use Filament \Actions \Action ;
10+ use InvalidArgumentException ;
511use Closure ;
612use Exception ;
7- use Filament \Forms \ComponentContainer ;
8- use Filament \Forms \Components \Actions \Action ;
9- use Filament \Forms \Components \Concerns \CanBeDisabled ;
1013use Filament \Forms \Components \Concerns \CanBeSearchable ;
11- use Filament \Forms \Components \Concerns \HasActions ;
1214use Filament \Forms \Components \Concerns \HasAffixes ;
1315use Filament \Forms \Components \Concerns \HasPivotData ;
1416use Filament \Forms \Components \Concerns \HasPlaceholder ;
15- use Filament \Forms \Components \Contracts \HasAffixActions ;
1617use Filament \Forms \Components \Field ;
17- use Filament \Forms \Form ;
1818use Filament \Support \Facades \FilamentIcon ;
1919use Illuminate \Database \Eloquent \Relations \BelongsTo ;
2020use Illuminate \Database \Eloquent \Relations \BelongsToMany ;
@@ -130,12 +130,12 @@ protected function setUp(): void
130130 }
131131 });
132132
133- $ this ->createOptionUsing (static function (SelectTree $ component , array $ data , Form $ form ) {
133+ $ this ->createOptionUsing (static function (SelectTree $ component , array $ data , Schema $ schema ) {
134134 $ record = $ component ->getRelationship ()->getRelated ();
135135 $ record ->fill ($ data );
136136 $ record ->save ();
137137
138- $ form ->model ($ record )->saveRelationships ();
138+ $ schema ->model ($ record )->saveRelationships ();
139139
140140 return $ component ->getCustomKey ($ record );
141141 });
@@ -310,7 +310,7 @@ public function prepend(Closure|array|null $prepend = null): static
310310 if (is_array ($ this ->prepend ) && isset ($ this ->prepend ['name ' ], $ this ->prepend ['value ' ])) {
311311 $ this ->prepend ['value ' ] = (string ) $ this ->prepend ['value ' ];
312312 } else {
313- throw new \ InvalidArgumentException ('The provided prepend value must be an array with "name" and "value" keys. ' );
313+ throw new InvalidArgumentException ('The provided prepend value must be an array with "name" and "value" keys. ' );
314314 }
315315
316316 return $ this ;
@@ -510,9 +510,9 @@ public function getHiddenOptions(): array
510510 return $ this ->evaluate ($ this ->hiddenOptions );
511511 }
512512
513- public function getCreateOptionActionForm (Form $ form ): array |Form |null
513+ public function getCreateOptionActionForm (Schema $ schema ): array |Schema |null
514514 {
515- return $ this ->evaluate ($ this ->createOptionActionForm , ['form ' => $ form ]);
515+ return $ this ->evaluate ($ this ->createOptionActionForm , ['form ' => $ schema ]);
516516 }
517517
518518 public function hasCreateOptionActionFormSchema (): bool
@@ -560,19 +560,19 @@ public function getCreateOptionAction(): ?Action
560560 }
561561
562562 $ action = Action::make ($ this ->getCreateOptionActionName ())
563- ->form (function (SelectTree $ component , Form $ form ): array |Form |null {
564- return $ component ->getCreateOptionActionForm ($ form ->model (
563+ ->schema (function (SelectTree $ component , Schema $ schema ): array |Schema |null {
564+ return $ component ->getCreateOptionActionForm ($ schema ->model (
565565 $ component ->getRelationship () ? $ component ->getRelationship ()->getModel ()::class : null ,
566566 ));
567567 })
568- ->action (static function (Action $ action , array $ arguments , SelectTree $ component , array $ data , ComponentContainer $ form ) {
568+ ->action (static function (Action $ action , array $ arguments , SelectTree $ component , array $ data , Schema $ schema ) {
569569 if (! $ component ->getCreateOptionUsing ()) {
570570 throw new Exception ("Select field [ {$ component ->getStatePath ()}] must have a [createOptionUsing()] closure set. " );
571571 }
572572
573573 $ createdOptionKey = $ component ->evaluate ($ component ->getCreateOptionUsing (), [
574574 'data ' => $ data ,
575- 'form ' => $ form ,
575+ 'form ' => $ schema ,
576576 ]);
577577
578578 $ state = $ component ->getMultiple ()
@@ -591,7 +591,7 @@ public function getCreateOptionAction(): ?Action
591591
592592 $ action ->callAfter ();
593593
594- $ form ->fill ();
594+ $ schema ->fill ();
595595
596596 $ action ->halt ();
597597 })
0 commit comments