© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•12mo ago•
29 replies
M.

Hide Create an action in the form of a filament

I have a code like this

'use HasAvailableLeaves;

protected function getFormActions(): array
{
return [
CreateAction::make('create')
->label(__('Request'))
->submit('create')
->hidden(HasAvailableLeaves::hideIfNoAvailableLeaves())
];
}'
I want this code to disappear according to the trait that I have created, but in a code condition like this I get an error
An attempt was made to evaluate a closure for [Filament\Actions\CreateAction], but [$get] was unresolvable.

Code in trait
'public static function hideIfNoAvailableLeaves(): Closure
{
return function ($get) {
$userId = $get('user_id');

if (!$userId) {
return false;
}

$availableLeaves = SheetLeave::where('user_id', $userId)->first()?->available_leaves ?? 0;

return $availableLeaves === 0;
};
}'
Solution
I have succeeded, currently I am using code like this
->hidden(fn ($livewire) => (SheetLeave::where('user_id', $livewire->data['user_id'])->first()?->available_leaves ?? 0) === 0)
->hidden(fn ($livewire) => (SheetLeave::where('user_id', $livewire->data['user_id'])->first()?->available_leaves ?? 0) === 0)

but will this cause any problems
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Create Another in a Form Action
FilamentFFilament / ❓┊help
3y ago
Hide close button in filament form
FilamentFFilament / ❓┊help
2y ago
Conditionally hide form in modal action
FilamentFFilament / ❓┊help
3y ago
Set the title of an action form
FilamentFFilament / ❓┊help
2y ago