'Create' - 'Create & create another' validation

Hi, I'm using a form within a resource. When I click the Create button, the form is validated using html's built in form validation whilst the Create & create another button seems to be validated on the server side. Same code, different behaviour. Is it possible to control whether to use local validation or server validation?
No description
No description
8 Replies
Patrick Boivin
Patrick Boivin14mo ago
I'm not sure, but I'm guessing the Create button is using a form submit and the Create & add another is using a Livewire method.
Naren
Naren14mo ago
Hi, I've encountered a similar issue when implementing a form within a Livewire component. The 'Create' button seems to trigger the default HTML form validation. Has anyone found a way to specify whether to use client-side (local) validation or server-side validation within Livewire?" I managed to find a solution to the issue. By adding the novalidate attribute to the form tag, I was able to bypass the default HTML form validation.
Strategic
Strategic14mo ago
Hey @Naren can you please share how did you manage to do it via ->extraAttributes(['novalidate']) ? Thank you so much for your time and help!!
awcodes
awcodes14mo ago
You can’t do this with extra attributes because that isn’t applied to the form. You would have to do a custom livewire component where you have control of the view and add the novalidate attribute to the form in your view.
Strategic
Strategic14mo ago
Wow .. ok .. thank you for taking the time to help...so basically i need to create my own /vendor/filament/filament/resources/views/resources/pages/create-record.blade.php for every resource ? or is there easier way?
awcodes
awcodes14mo ago
Other option is to define your validation rules inside the rules() modifier instead of using the required() modifier for example on your form fields. But, honestly it’s better to let the browser handle html level field validation where possible as it prevents unnecessary network requests.
Strategic
Strategic14mo ago
i see.. thank you .. well if it only would be possible to control the message some how for consistency..
Miguel García
Miguel GarcíaOP14mo ago
If I'm not wrong, the Create and create another always uses server side validation even when you use the required() modifier, is there any way to force html validation for that button? It would be great if both buttons behaved the same.
Want results from more Discord servers?
Add your server