F
Filament6mo ago
Andy

Standalone action not hiding

I'm getting what feels like weird behaviour with an action. I'd like to conditionally hide the action but using ->hidden() just disables it.
public function testAction(): Action
{
return Action::make('test')
->hidden()
->label('Test Action')
->action(fn () => dd('TODO'));
}

public function testAction(): Action
{
return Action::make('test')
->hidden()
->label('Test Action')
->action(fn () => dd('TODO'));
}

No description
2 Replies
DrByte
DrByte6mo ago
Should hidden() be visible(Closure)?
LeandroFerreira
LeandroFerreira6mo ago
you should check the visibility in the view
{{ ($action = $this->testAction())->isVisible() ? $action : '' }}
{{ ($action = $this->testAction())->isVisible() ? $action : '' }}