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
morawcikOP6mo ago
Anyone? 😦
micraux
micraux6mo ago
Hi, There is no rule named accepted: are you using a custom rule?
morawcik
morawcikOP6mo 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
LeandroFerreira6mo 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
morawcikOP6mo 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
LeandroFerreira6mo ago
did you do $this->form->fill() in the mount method?
morawcik
morawcikOP6mo 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 Koch6mo 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