© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•16mo ago
bwurtz999

Reuse Component Function

Hello - is there a way to reuse a function on a form component? For example, I have a
Select
Select
element and I only want it to be required if it is visible
Select::make('name')
->required(function ($get) {
    $id = $get('category_id');
    $category = Category::find($id);
    return !$category->page_one;
})
->visible(function ($get) {
    $id = $get('category_id');
    $category = Category::find($id);
    return !$category->page_one;
})
Select::make('name')
->required(function ($get) {
    $id = $get('category_id');
    $category = Category::find($id);
    return !$category->page_one;
})
->visible(function ($get) {
    $id = $get('category_id');
    $category = Category::find($id);
    return !$category->page_one;
})


I have to write two separate checks - one for visible and one for required. But they are the same thing. It feels inefficient. Is there a better way to do this? Thank you
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

Reuse resource form in another livewire component
FilamentFFilament / ❓┊help
3y ago
Reuse filament select multiple in custom component
FilamentFFilament / ❓┊help
3y ago
Reuse infolist
FilamentFFilament / ❓┊help
3y ago
How to reuse functions using services
FilamentFFilament / ❓┊help
2y ago