Copy Action

Hello everyone, I have the code below. When copyFieldsToState is triggered, I want to copy specific data. How can I proceed this way? Currently, I can only print it with a notification. ->hintAction( Action::make('copyFieldsToState') ->icon('heroicon-m-clipboard') ->action(function (array &$state, Get $get) { if (!isset($state['copiedData'])) { $state['copiedData'] = ''; } $copiedData = collect($get('ships') ?? [])->map(function ($ship) { return "Name: {$ship['name']}, IMO: {$ship['imo']}, Hull No: {$ship['hull_no']}, Shipyard ID: {$ship['shipyard_id']}"; })->implode("\n---\n"); $state['copiedData'] = $copiedData; Notification::make() ->title('Fields copied to state') ->body(nl2br(e($copiedData))) ->success() ->send(); }) )
Solution:
FilamentPHP Glow
Custom copy action, click the icon to copy the content
Jump to solution
4 Replies
Solution
Lara Zeus
Lara Zeus5mo ago
FilamentPHP Glow
Custom copy action, click the icon to copy the content
cenksen
cenksenOP5mo ago
@Lara Zeus Thx
Dennis Koch
Dennis Koch5mo ago
@cenksen please read our #✅┊rules and format your code properly in the future
cenksen
cenksenOP5mo ago
okay thx @Dennis Koch
Want results from more Discord servers?
Add your server