F
Filament3mo ago
AKM

Set Action as iconButton() specifically handle record actions not overall

is there any way to set record action as icon button globally without change one by one in every action and resources ?
Solution:
Just tried the same example by @Oscar Carvajal but with EditButton, works for me: ``` use Filament\Actions\EditAction; ...
Jump to solution
6 Replies
Oscar Carvajal Mora
Inside any service provider's boot() method, you can apply global settings calling the static coonfigureUsing() component method. I always create a "CustomizationServiceProvider.php" with all my Filament customizations
No description
AKM
AKMOP3mo ago
Thanks, bro. I really appreciate it. This works, but it will need some extra steps for actions that require labels, like the header action, login button, and form action button. I was just wondering if there’s a global function that could specifically handle record actions in tables using only the button icon, without changing the default button view overall. That’s what I was trying to ask.
Solution
Povilas Korop
Povilas Korop3mo ago
Just tried the same example by @Oscar Carvajal but with EditButton, works for me:
use Filament\Actions\EditAction;

class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
EditAction::configureUsing(function (EditAction $action) {
$action->iconButton();
});
}
}
use Filament\Actions\EditAction;

class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
EditAction::configureUsing(function (EditAction $action) {
$action->iconButton();
});
}
}
Povilas Korop
Povilas Korop3mo ago
result:
No description
Oscar Carvajal Mora
Oh, got it! What @Povilas Korop says works too. But, as I understand it now, you are referring to scope the changes only to table edit record actions, is that right? If it is, I think that the best approach for that is to make a custom action, extending from Edit Action, and use this custom action inside your table record actions. What @Povilas Korop is a good approach but, I'm pretty sure that it will change page header Edit Action too and, only to check if I understand your requirement, you don want that right?. An example of what I mean to creating a custom edit recor action:
// Inside any resource table
public static function configure(Table $table): Table
{
return $table
->columns([
//
])
->recordActions([
// EditAction::make(), -> Instead of use this built-in action
CustomRecordEditAction::make() // Use your custom edit record action
]);
}
// Inside any resource table
public static function configure(Table $table): Table
{
return $table
->columns([
//
])
->recordActions([
// EditAction::make(), -> Instead of use this built-in action
CustomRecordEditAction::make() // Use your custom edit record action
]);
}
And then, you can implement your Custom Record Edit Action like this:
class CustomRecordEditAction extends EditAction
{
protected function setUp(): void
{
parent::setUp();
$this->iconButton();
}
}
class CustomRecordEditAction extends EditAction
{
protected function setUp(): void
{
parent::setUp();
$this->iconButton();
}
}
(Sorry for miss formatting the table example, but idk why is not taking the comment lines on actions)
AKM
AKMOP3mo ago
oh, great it work as well expected, in my opinion the simple way is register specific record action into service provider, but i really appreciate it.

Did you find this page helpful?