© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
6 replies
Wirkhof

How to save the value of hidden toggle?

I have two toggles.

If the first one is on, it will show the second toggle.

If the frist one is off, it will hide the second toggle.

I am using this on the first toggle to set the value to off when offing the first toggle:

->afterStateUpdated(function (Set $set, $state) {
    if ($state === false) {
        $set('second_thing', false);
    }
})
->afterStateUpdated(function (Set $set, $state) {
    if ($state === false) {
        $set('second_thing', false);
    }
})

The problem is that while it seems to be working in the form visually, it is not saving the state of the second toggle (second_thing) in the DB, just the first toggle is saved correctly. As if the afterStateUpdated doesn't propagate to the save method?

Because if I manually (click with the mouse) on the second toggle directly to the state I want and press save - it is saved correctly.

How to alter the afterstateupdated method (or use something else) to save it correctly?
Solution
try here https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-saving
Editing records - Panel Builder - Filament
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Toggle reverting to previous value on save
FilamentFFilament / ❓┊help
2y ago
Toggle fieldsets visibility, but also save hidden data.
FilamentFFilament / ❓┊help
7mo ago
Save hidden field
FilamentFFilament / ❓┊help
3y ago
Toggleable with hidden
FilamentFFilament / ❓┊help
2y ago