© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Bumpyy

Default value for Settings page form

I'm using the Spatie Settings plugin but some input need to be able to be empty, the problem is that the page will display error if some input have no data, is there an easy way to save value to empty string if user input no data, other than using lifecycle hook (i'm using mutateFormDataBeforeSave, but it's a pain if the page have many form) ?
Solution
in the end i'm using array_map in mutateFormDataBeforeSave

protected function mutateFormDataBeforeSave(array $data): array
{
//? Loop through data and check if there's null value then replace it with empty string.
$data = array_map(function ($value) {
return $value === null ? "" : $value;
}, $data);

return $data;
}
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

Settings Select form component default value in relation
FilamentFFilament / ❓┊help
2mo ago
form select assign default value
FilamentFFilament / ❓┊help
3y ago
default value in custom page
FilamentFFilament / ❓┊help
3y ago
form input default value not passed
FilamentFFilament / ❓┊help
3y ago