Validation messages not working on custom page?

Hi, I have custom page
class Company extends Page implements HasForms {
use InteractsWithForms;

// ....
}
class Company extends Page implements HasForms {
use InteractsWithForms;

// ....
}
Each field has custom error messages like
->validationMessages([
'accepted' => 'Custom error message',
])
->validationMessages([
'accepted' => 'Custom error message',
])
but submitting form shows the default Laravel messages.
8 Replies
morawcik
morawcikOP5mo ago
Anyone? 😦
micraux
micraux5mo ago
Hi, There is no rule named accepted: are you using a custom rule?
morawcik
morawcikOP5mo ago
There is - for e.g. by using ->accepted() (from vendor/filament/forms/src/Components/Concerns/CanBeAccepted.php) but it can be any validation message/rule and it not works as well.
LeandroFerreira
LeandroFerreira5mo ago
Are you using a statePath? Are you doing this?
->rule('accepted')
->validationMessages([
'accepted' => 'Custom error message'
])
->rule('accepted')
->validationMessages([
'accepted' => 'Custom error message'
])
morawcik
morawcikOP5mo ago
Yes, I'm using statePath('data') I'm doing this:
Checkbox::make('rules')
->label(fn() => new HtmlString('Please accept the <a href="/rules"><u>rules</u></a>'))
->accepted()
->validationMessages([
'accepted' => 'Custom error message',
])
->columnSpanFull()
Checkbox::make('rules')
->label(fn() => new HtmlString('Please accept the <a href="/rules"><u>rules</u></a>'))
->accepted()
->validationMessages([
'accepted' => 'Custom error message',
])
->columnSpanFull()
For this page all rules I'm using through filament - like accepted() required() or maxLength()
LeandroFerreira
LeandroFerreira5mo ago
did you do $this->form->fill() in the mount method?
morawcik
morawcikOP5mo ago
Oh boy, I was sure it's when I want populate form with model data... I'm so dumb. Thank you so much.
Dennis Koch
Dennis Koch5mo ago
It’s not. That’s why it’s mentioned at the start of the docs 🙈
Want results from more Discord servers?
Add your server