F
Filamentβ€’14mo ago
Altffenser

Text to case...

Hello devs! I am looking for a function that convert text to uppercase (or title case) in TextInput or TextArea, you know any implementation to do it? I usually do it with javascript but I can't find a way to inject JS into the component.
6 Replies
cheesegrits
cheesegritsβ€’14mo ago
Do you want to do it on submit, or "live" in the form when the blur out of the input?
Altffenser
AltffenserOPβ€’14mo ago
Interesting question. I would like it to be live. πŸ˜„
cheesegrits
cheesegritsβ€’14mo ago
You could try something like ...
TextInput::make('foo')
->lazy()
->afterStateUpdated(fn (string $state, Form\Set $set) => $set('foo', strtoupper($state)),
TextInput::make('foo')
->lazy()
->afterStateUpdated(fn (string $state, Form\Set $set) => $set('foo', strtoupper($state)),
Altffenser
AltffenserOPβ€’14mo ago
Working but not as expected. 😦
DrByte
DrByteβ€’14mo ago
How "not expected"?
Altffenser
AltffenserOPβ€’14mo ago
https://stackoverflow.com/a/45067218 I found this answer, check the behavior with Hugh Messenger's solution.
Stack Overflow
Change Input to Upper Case
JS: <script type="text/css"> $(function() { $('#upper').keyup(function() { this.value = this.value.toUpperCase(); }); }); </script> HTML <div id="search"> ...
Want results from more Discord servers?
Add your server