How to get the length of a field?

"TextInput::make('zip_code') ->helperText('Please enter at least 5 character and maximum 12 characters') ->reactive() ->minLength(5) ->maxLength(12) ->required()," I have this text input and I want to get its length to render another field conditionally. Is there a way to do this?
4 Replies
Dennis Koch
Dennis Kochβ€’2y ago
Use closure customization, $get() and strlen()
toeknee
toekneeβ€’2y ago
To refine Dennis answer: ->visible(fn(Closure $get, $set) => strlen($get('zip_code')) > 12) on the field you want shown conditionally would show the field if the string length is greater than 12
ZedoX
ZedoXβ€’2y ago
Are you perhaps looking for? #charcount-field
DianaMujoiu
DianaMujoiuOPβ€’2y ago
Thank you, guys! πŸ˜€ I was looking for Toeknee answer
Want results from more Discord servers?
Add your server