Reset an Inertia form after it saves

onSuccess can reset one field after a save. Resetting before the redirect drops the value you meant to send.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/inertia-on-success-reset-vue.md
onSuccess can reset one field after a save. Resetting before the redirect drops the value you meant to send.
Do not call form.reset() in the submit handler before form.post.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Inertia reset form on success” clear the inputs on the click, then the request goes out empty. Reset after Laravel accepts the row.

TL;DR

  • onSuccess can reset one field after a save.
  • Resetting before the redirect drops the value you meant to send.
  • Do not call form.reset() in the submit handler before form.post.
  • Do not reset on onError.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

The CRUD guide redirects to the list, which unmounts the form. You only need onSuccess when the user stays on the same page, such as a comment box under a post.

vue
<script setup lang="ts">
import { useForm } from "@inertiajs/vue3";

const form = useForm({ body: "" });

function submit() {
  form.post("/comments", {
    preserveScroll: true,
    onSuccess: () => form.reset("body"),
  });
}
</script>

onSuccess runs when the visit finishes without validation errors. form.reset("body") clears that key and its error. Other keys stay.

What to avoid#

Gotcha

Do not call form.reset() in the submit handler before form.post. The payload is already empty by the time Inertia reads it. Do not reset on onError. The user needs the text they just typed in order to fix it.

FAQ#

How do I reset an Inertia form after it saves?

onSuccess can reset one field after a save. Resetting before the redirect drops the value you meant to send.

What goes wrong with Inertia reset form on success?

Many developers clear the inputs on the click, then the request goes out empty. Do not call form.reset() in the submit handler before form.post.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.