Trim Text Inputs
How do I trim all TextInputs before saving to the database? I would've thought this would have been automatic because of the Laravel TrimStrings middleware but I can still added whitespace characters before and after the string and they still save.
4 Replies
Have you ensured the middleware is applied to your panel ?
https://filamentphp.com/docs/3.x/panels/configuration#applying-middleware
Maybe you can use
TextInput::configureUsing()
method in panel provider boot method.I would've thought this would have been automatic because of the Laravel TrimStrings middleware but I can still added whitespace characters before and after the string and they still save.Strings aren't trimmed in Livewire because it would break the "live" mode
Time to add some test cases to make sure everythings trimmed. Whats the easiest way to add trim on a TextEntry? 👀