© 2026 Hedgehog Software, LLC

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

TextInput default value on edit page

Hi, I want to set a default value on a form text input. I'm adding the
->default('some default string')
->default('some default string')
property but it only works on Create, in the edit it doesn't works even though the value is empty or null.

For example, I need this for when I add a new field to the form and for example a user accesses the form when they had previously saved it. So that this field appears already filled in with the default value.
Solution
You have many way to do that and you have choose the proper one according to your scenario:
- Use mutator in your Eloquent as @PovilasKorop said.
- Use
->mutateFormDataUsing()
->mutateFormDataUsing()
chain or
mutateFormDataBeforeSave()
mutateFormDataBeforeSave()
lifecycle method.
- If you need to show the default value to the user, you can use
->formatStateUsing()
->formatStateUsing()
and in the callback, check if the $state is null then return you default value
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

TextInput default value at ViewResource page
FilamentFFilament / ❓┊help
3y ago
TextInput Default value
FilamentFFilament / ❓┊help
3y ago
Give default value to TextInput when Edit Data
FilamentFFilament / ❓┊help
2y ago
TextInput, set default value (from backend)
FilamentFFilament / ❓┊help
2y ago