F
Filament•2mo ago
core

->maxLength() not working on textinput

Forms\Components\TextInput::make('note')->maxLength(2)
Forms\Components\TextInput::make('note')->maxLength(2)
this is not validating
7 Replies
Dennis Koch
Dennis Koch•2mo ago
We need some more info 🤷🏼‍♀️
Expecto Patronum
Expecto Patronum•2mo ago
What error did you get?
core
core•2mo ago
i get no message/error, followed the docs. expected behaviour : get message that I exceeded the max length. this is inside a relationsmanager form
Expecto Patronum
Expecto Patronum•2mo ago
Can you show your code? Maybe can share the file here to debug
awcodes
awcodes•2mo ago
->maxLength() adds the maxlength attribute to the input meaning the user can’t type more than two characters. It does add the validation as well but since the input is maxed at two it will not trigger an error. If that is not the behavior you want then you’ll need to use ->rules() instead.
core
core•2mo ago
the input still lets me add more than the max so that is weird
awcodes
awcodes•2mo ago
That is very weird. At the least it should trigger a browser validation error if it doesn’t act in accordance with the expected behavior.