File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 1010use Filament \Forms \Components \Concerns \CanBeSearchable ;
1111use Filament \Forms \Components \Concerns \HasActions ;
1212use Filament \Forms \Components \Concerns \HasAffixes ;
13+ use Filament \Forms \Components \Concerns \HasPivotData ;
1314use Filament \Forms \Components \Concerns \HasPlaceholder ;
1415use Filament \Forms \Components \Contracts \HasAffixActions ;
1516use Filament \Forms \Components \Field ;
@@ -26,6 +27,7 @@ class SelectTree extends Field implements HasAffixActions
2627 use HasActions;
2728 use HasAffixes;
2829 use HasPlaceholder;
30+ use HasPivotData;
2931
3032 protected string $ view = 'select-tree::select-tree ' ;
3133
@@ -103,6 +105,12 @@ protected function setUp(): void
103105 // Wrap the state in a collection and convert it to an array if it's not set.
104106 $ state = Collection::wrap ($ state ?? []);
105107
108+ if ($ pivotData = $ component ->getPivotData ()) {
109+ $ component ->getRelationship ()->syncWithPivotValues ($ state ->toArray (), $ pivotData );
110+
111+ return ;
112+ }
113+
106114 // Sync the relationship with the provided state (IDs).
107115 $ component ->getRelationship ()->sync ($ state ->toArray ());
108116 }
You can’t perform that action at this time.
0 commit comments