© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•5mo ago•
5 replies
borg

OptionStateCast forces casting of option keys to integer

@Dan Harrin Any particular reason why would you force the type to integer? This last update does solve for keys starting with zero, but to be honest I currently don't agree. In my particular case, I have keys in this fashion "0011, 1025, 5568" which I'd like to keep as strings no matter what. Changing the type throughout the application can have side effects. My DB columns is JSON and the values get's stored as string in case of leading zeroes and integer in other cases.

I solved this with setting my custom cast with ->stateCasts(), now after this update: https://github.com/filamentphp/filament/pull/17902/files I solved with Cutom Laravel casts, since you keep numbers starting with zero as strings.

Not everyone knows this if they don't source dive and will have issues.

TLDR: Why do you force integer if ctype_digit return true? Maybe have an option that keeps string eg
->enforceStringState()
->enforceStringState()
.

I will consider a PR for this, but I'd just like to know the reasoning behind this. I may be wrong with my input.

Thank you!
GitHub
fix: Option keys starting with 0 by danharrin · Pull Request #1790...
fix: Option keys starting with 0 by danharrin · Pull Request #1790...
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

Value object casting
FilamentFFilament / ❓┊help
2y ago
Sort by integer?
FilamentFFilament / ❓┊help
3y ago
Using Laravel-data casting
FilamentFFilament / ❓┊help
3y ago
How to turn off casting during seeding?
FilamentFFilament / ❓┊help
2y ago