Here is a first way, you could actually do this right now:
<form wire:submit.prevent="submit(Object.fromEntries(new FormData($event.target)))">
<input type="text" name="foo">
<input type="text" name="bar">
<button>Submit</button>
</form>
Then, in your component, here’s the submit method:
public function submit($formData)
{
dd($formData);
}
After typing in “baz” and “bob” into the inputs and submitting, this will output:
![](http://i0.wp.com/saifiweb.com/wp-content/uploads/2021/04/form-data.png)
I'm Murad Saifi, an experienced freelance website designer and developer with over 5 years of industry expertise. Specializing in PHP and the Laravel Framework, I've successfully delivered diverse projects, including e-commerce websites, CRM, CMS platforms, matrimony website and web portals. With skills in crafting secure back-end panels, integrating APIs, and payment gateways, I ensure seamless functionality.
During my free time, I enjoy writing blogs on various topics like web technology, internet trends, android, website security, AI, and ChatGPT. With a deep passion for the industry and a commitment to staying up-to-date, I share valuable insights and expertise on my blog. Join me as we explore the ever-evolving world of web design, development, and the exciting realm of technology.