Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Livewire and a form request for fields validation ?

Hello,

I like using form requests to validate the fields when I use standard routes for CRUD.

The Livewire documentation says that it's possible to validate the fields by defining a rules() function.

As there is already this function in a form request, how is it possible to use a standard Laravel form request to validate the different fields in a Livewire form ?

Would it be as simple as returing (new CategoryRequest)->rules() from the Livewire rules() function ? Or is there another way to that properly ?

Thanks for your help.

V

0 likes
2 replies
martinbean's avatar
Level 80

@vincent15000 You don’t use form requests in Livewire components, as Livewire components don’t work with a single request. If you want to re-use rules, then abstract them to their own validation class that both the form request and Livewire component can make use of, instead of trying to misuse the form request.

1 like
vincent15000's avatar

@martinbean Thank you, that's exactly what I needed to know ;). Sure I didn't want to use the form request directly, by effectively, as you say, abstract the rules is a good idea.

1 like

Please or to participate in this conversation.