Display Action Text in Table as Button

Using the following code below, is there a simple way to change the current Icon and Text for the Action to a button instead without having to create a custom column?
protected function getTableActions(): array
{
return [
Action::make('updateShipping')
->action(function (Model $record, array $data): void {
$record->ConfirmationNumber = $data['ConfirmationNumber'];
$record->save();
\Mail::to($record->EmailAddress)->send(new \App\Mail\TrackingNumber($record));
})
->icon('heroicon-o-truck')
->label('SHIP')
->form([
TextInput::make('ConfirmationNumber')
->label('Delivery Confirmation #')
->required(),
])

];

}
protected function getTableActions(): array
{
return [
Action::make('updateShipping')
->action(function (Model $record, array $data): void {
$record->ConfirmationNumber = $data['ConfirmationNumber'];
$record->save();
\Mail::to($record->EmailAddress)->send(new \App\Mail\TrackingNumber($record));
})
->icon('heroicon-o-truck')
->label('SHIP')
->form([
TextInput::make('ConfirmationNumber')
->label('Delivery Confirmation #')
->required(),
])

];

}
7 Replies
Patrick Boivin
Hi @rubendn, have you tried :
Action::make('updateShipping')
// ...
->button()
Action::make('updateShipping')
// ...
->button()
rubendn
rubendnOP2y ago
Thank You! That works great. One more question, is the positioning of Actions in a table only the default END or BEGINNING of the table? Is there a way to position an action among the columns in the middle somewhere?
toeknee
toeknee2y ago
Not with an action, you can make the column actionable instead opposed to a table action
rubendn
rubendnOP2y ago
If I’m adding an action on a textcolumn how do I define the modal?
toeknee
toeknee2y ago
You can do ->form then action handles the data and map to model saves it If memory serves me right
rubendn
rubendnOP2y ago
Thank you for leading me in the right direction... This worked:
Tables\Columns\TextColumn::make('tracking')
->action(
Action::make('updateShipping')
->action(function (Model $record, array $data): void {
$record->ConfirmationNumber = $data['ConfirmationNumber'];
$record->save();
\Mail::to($record->EmailAddress)->send(new \App\Mail\TrackingNumber($record));
})
->form([
TextInput::make('ConfirmationNumber')
->label('Delivery Confirmation #')
->required(),
]))
->icon('heroicon-o-truck')
->label('Tracking')
->placeholder('SHIP'),
Tables\Columns\TextColumn::make('tracking')
->action(
Action::make('updateShipping')
->action(function (Model $record, array $data): void {
$record->ConfirmationNumber = $data['ConfirmationNumber'];
$record->save();
\Mail::to($record->EmailAddress)->send(new \App\Mail\TrackingNumber($record));
})
->form([
TextInput::make('ConfirmationNumber')
->label('Delivery Confirmation #')
->required(),
]))
->icon('heroicon-o-truck')
->label('Tracking')
->placeholder('SHIP'),
toeknee
toeknee2y ago
Very welcome dude!
Want results from more Discord servers?
Add your server