© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
Marco Mapelli

disable field dynamically but save it in db

Hi, I need to dynamically disable a Togglebut I have to save the field: how come it doesn’t work ?
...
        switch ($tipo) {
            case SoggettoTipo::Contraente:
                $is_contraente = true;
                $is_contraente_disabled = true;
                break;
            case SoggettoTipo::DlDecRup:
                $is_dldecrup = true;
                $is_dldecrup_disabled = true;
                break;
        }
...
                Toggle::make('is_contraente')
                    ->default($is_contraente)
                    ->dehydrated()
                    ->disabled($is_contraente_disabled),
...
        switch ($tipo) {
            case SoggettoTipo::Contraente:
                $is_contraente = true;
                $is_contraente_disabled = true;
                break;
            case SoggettoTipo::DlDecRup:
                $is_dldecrup = true;
                $is_dldecrup_disabled = true;
                break;
        }
...
                Toggle::make('is_contraente')
                    ->default($is_contraente)
                    ->dehydrated()
                    ->disabled($is_contraente_disabled),
Solution
Perfect !!
                Forms\Components\Toggle::make('is_contraente')
                    ->default($is_contraente)
                    ->disabled($is_contraente_disabled)
                    ->dehydrated(),
                Forms\Components\Toggle::make('is_contraente')
                    ->default($is_contraente)
                    ->disabled($is_contraente_disabled)
                    ->dehydrated(),

Thanks
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

Save multiple events in the DB
FilamentFFilament / ❓┊help
2y ago
save placeholder field
FilamentFFilament / ❓┊help
3y ago
Save hidden field
FilamentFFilament / ❓┊help
3y ago