validation
I'm getting to know laravel filament, and I have a problem when sending the form to create it with the "Create" button, the error messages don't appear only like the native browser,
but if I send "Create & create another" the error message are displayed.
I've been struggling with this for a while, do you have experience with it? I am trying also completely new instalation, but stil is the same
I would like the error messages to be displayed in the same way during create and edit. This is the same on all forms
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('city')
->required()
->maxLength(255),
Forms\Components\TextInput::make('country')
->required()
->maxLength(255),
Forms\Components\TextInput::make('postal_code')
->required()
->maxLength(255),
]);
}
Thank you
2 Replies
Some validation modifiers like required and maxLength add those attributes to the html input, which triggers browser validation. That’s done to save on server calls. If you want to not use browser validation then you’ll need to use ->rules() instead of the individual modifiers.
And the reason it’s different for the create and another is because that is a standard button vs the create which is a submit button for the form. Browser validation only happens on form submit.
thank you, for answer I tried to use ->rules with som condition, but still same I understand that js validation is before the submit form. But I new in Filament and I am usualy using jquery validation and I looking for something similar that.