validationMessages not work
Forms\Components\TextInput::make('codpos')->numeric()->integer()->maxLength(5)
->validationMessages([
'maxLength' => 'La longitud del campo es incorrecta'
]),
Solution:Jump to solution
Forms\Components\TextInput::make('codpos')->numeric()->integer()->maxLength(5)
->validationMessages([
'max_digits' => 'La longitud del campo es incorrecta'
]),...
4 Replies
Resuelto
Solution
Forms\Components\TextInput::make('codpos')->numeric()->integer()->maxLength(5)
->validationMessages([
'max_digits' => 'La longitud del campo es incorrecta'
]),
I just tried to reproduce, worked well for me:
So I guess the problem is not in Filament itself but in somewhere else where you store validation lang maybe, in the Laravel /lang folder?
Or maybe you need to update your Filament/Laravel?
The key in the array in validationMessages must match the value in the laravel documentation. This is not always obvious. For maxLength - the value is "max_digits". So the message should be 'max_digits' => 'La longitud del campo es incorrecta'. Sometimes it matches - like requiredIf - is required_if. I spent 2+ hours in the debugger figuring this out. Would be happy to update the documentation - but I don't know how to contribute there.