F
Filament13mo ago
_Lietze

Copy to clipboard action table

Would anyone know an easy way to make an action that copies a certain value to the users clipboard? Thanks in advance!
No description
10 Replies
_Lietze
_LietzeOP13mo ago
at the moment i have this, but i'm really not sure how to implement the already-existing ->copyable() method into this action
->actions([
ViewAction::make(),
EditAction::make(),
Action::make('Copy address')
->icon('heroicon-o-clipboard')
->dispatch(fn (User $user) => null)
// some code to copy the address to the clipboard
])
->actions([
ViewAction::make(),
EditAction::make(),
Action::make('Copy address')
->icon('heroicon-o-clipboard')
->dispatch(fn (User $user) => null)
// some code to copy the address to the clipboard
])
It doesn't have to be an action, but i just want some way of copying the address text, without showing the entire address in the table data. preferably a single button with an icon (no text) :p
Vp
Vp13mo ago
_Lietze
_LietzeOP13mo ago
That's a pretty good (and simple) solution, thanks @Vp ! Would you know if it's possible to make some copy button for in the forms too?
Vp
Vp13mo ago
Not sure, because I don't know how to write copyable code using PHP.. if you can hook some JS then you can achieve maybe 🤣
_Lietze
_LietzeOP13mo ago
yeah but doing that from Filament would be tough hahaha
Vp
Vp13mo ago
Not sure, because using your main idea may achieve, you create Action, inside ->action() in Action you call JS (this js part I don't know rn) then you may achieve..
Dennis Koch
Dennis Koch13mo ago
Maybe check the copyable implementation and adapt to your needs
_Lietze
_LietzeOP13mo ago
yes but then it would be pretty ugly code, calling JS from a filament action lol I'll check that out, thanks! Filament\Support\Concerns\CanBeCopied is a trait though, so i'm not sure how i would implement that onto TextArea hahahha The only solution I would be able to think of is making a copy of TextArea, and make sure it uses CanBeCopied, but I'm not even sure if that would work, and if that is the best solution for this. @Dennis Koch Do you think this would work, or did you mean something else with a copyable implementation?
Dennis Koch
Dennis Koch13mo ago
Why Textarea? I thought you want to use this on an action?!
_Lietze
_LietzeOP13mo ago
The action i've replaced with a textcolumn that's copyable. Now i'm also trying to get the same copyable functionality onto the view page of my user resource I was trying to get the forms to work too https://discord.com/channels/883083792112300104/1171395108931907614/1171397523299106916 Not sure if this is possible though
Want results from more Discord servers?
Add your server