Laravel comes with quite an effective out-of-the-box solution for validation. Most of the documentation covers handling validation for a single form on a page. But what if you have many forms? Chances are you might have some fields with the same name attribute.
Taking a look at Google, the most common solution I came across is to prefix the field names like
login_username i.e in form_name_field_name format. Which works, however, doing so means now you have to tell Laravel to do something like:
$this->validate($request, [ 'post_body' => 'required_without:post_image|max:1000', 'post_image' => 'required_without:post_body|image|mimes:jpeg,png,jpg,gif,svg|max:2048' ], , [ 'post_body' => 'post', 'post_image' => 'attached file', ]);
So, I set out to experiment a bit and come up with other solutions. One of my first attempts at this is up on my GitHub.
Check out the zaxwebs/ex-l8-multi-forms repo.