Standalone form validation
im having another brain fart. When doing a standalone form with a submit button that is tied to submit(), how can ensure rules() within the form are valid before it will submit? simple things like required halt it using a standard html5 response, but a custom rules() does not. I am using
16 Replies
@leandro_ferreira no dice
BEFORE submit only happens with browser validation
php functions are not part of browser validation
only a limited set of rules are supported like required, maxlength, numeric
sorry, I assumed that your function wasn't working
so with php then and doing a submit() method, is there a way to enforce those per field rules in some fashion or am i forced to create all the validation within the submit using the normal laravel methods?
Html5 validation only works with certain attributes on certain types of inputs. Given your example there would be no way to do a native validation against a server side variable without a request.
i fully understand that
While JavaScript validation is an option as well, it requires duplicating your frontend/backend validation rules. In my opinion, utilizing Laravel's validation is the superior approach.
Im really confused here. Obviously rules() has a place outside of just html5 validation, correct?
I mean, i dont care if it does a request or not
Of course it does, but since it needs a request it can’t disable the submit.
ok, so with the submit(), how do you utilize those rules....
Once it’s submitted running $this->form->getState() will run the validation and should kick back with any errors.
thanks. thats all i needed. This form isnt for saving any data from the actual form, so i wasnt doing that, thus the validation wasnt happeing.
Filament
Getting started - Form Builder - Filament
The elegant TALL stack form builder for Laravel artisans.
yep, i see that at the bottom. my problem is that i wasnt looking at the docs for getting data, i had looked at the validation section