Get all field data after form submit in Livewire

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:

Leave a Reply

Your email address will not be published. Required fields are marked *