© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•8mo ago•
1 reply
vahnmarty

Lazy Mode with Conditional Visibility & Custom AutoSave Behavior

I'm building a Filament form and I want to implement two behaviors for my fields:

1. Conditional Visibility
I want the TextInput field (answer) to only be visible if the Select field (question) has a value of
1 (Yes)
1 (Yes)
. If
0 (No)
0 (No)
, it should hide the TextInput.

2. Per-Field AutoSave (on Submit Only)
Each field has an
autoSave()
autoSave()
function that should be triggered only on form submission (or a button click).
However, when changing the Select field (to toggle visibility), I want to prevent triggering autoSave on the hidden/shown field. Basically:

✅ autoSave should run on submit

❌ autoSave should not run when Select changes

Here's my current setup:

Select::make('question')
    ->options([
        1 => 'Yes',
        0 => 'No'
    ])
    ->required(),

TextInput::make('answer')
    ->lazy()
    ->required()
    ->dehydrateStateUsing(function ($state) {
        
    })
    ->afterStateUpdated(function (TextInput $component, $state) {
        // currently runs on change – I want to skip this if just toggled
        // $this->autoSave('answer', $state);
    })
Select::make('question')
    ->options([
        1 => 'Yes',
        0 => 'No'
    ])
    ->required(),

TextInput::make('answer')
    ->lazy()
    ->required()
    ->dehydrateStateUsing(function ($state) {
        
    })
    ->afterStateUpdated(function (TextInput $component, $state) {
        // currently runs on change – I want to skip this if just toggled
        // $this->autoSave('answer', $state);
    })


My Questions:
How can I conditionally show/hide the TextInput based on the Select value?

How do I suppress autoSave on afterStateUpdated() when visibility is toggled?

Is there a clean way to handle this without triggering unnecessary saves?

Any best practices or suggested patterns are welcome!
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

Conditional visibility of form fields
FilamentFFilament / ❓┊help
15mo ago
Conditional visibility of Repeater extraActions
FilamentFFilament / ❓┊help
2y ago
Conditional tab visibility triggers weird form glitch
FilamentFFilament / ❓┊help
15mo ago
Conditional Custom Theme
FilamentFFilament / ❓┊help
2y ago