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

jorisvanandel's avatar

Inertia form not updating when page props change.

I have a Team model that contains Users. The Team page shows information about the team, including it's users and has a button to add a user to that team.

The page layout looks something like this:

<script setup>
...
const props = defineProps({
    team: Object
});

const form = useForm({
    name: props.team.name,
	...
    users: props.team.users
});
</script>
<template>
	<div class="space-y-2" v-else>
                <div v-for="(user, userIdx) in form.users" :key="userIdx">
                    ...
                </div>
            </div>
</template>

When I add a user (which is just a form.post request to a controller that performs a redirect()->back() action when finished, the form is not updated and the list does not show the newly created user. How do I make this form reactive? My guess would be to add a watcher to the props, but that doesn't work. I can't think of any other clean solution.

0 likes
9 replies
tykus's avatar

Force the form reset in the options, e.g.

onSuccess: () => form.reset()

jorisvanandel's avatar

@tykus Unfortunately, that doesn't work. The users property on the form still remains an empty array until I refresh.

1 like
jorisvanandel's avatar

I fixed it by adding this watcher

watch(() => props.team,
    (team) => form.users = team.users
);

Not the cleanest solution but at least it works!

2 likes
robert-assurant's avatar

@fredpedersen This is correct. Make sure you are specifically setting that to false.

But when you do that you cannot use the other form helpers like form.recentlySuccessful

leopardat1's avatar

I am in the same situation and I really really want to keep using the form.recentlySuccessful helper so that I can display a proper 'finish updating' message after submission.

preserveState: false or preserveState: 'errors' works but takes away the other benefits preserving a state comes with. There is no other way to work around this?

Nafario's avatar

@leopardat1 The onSuccess function has page parameter; onSuccess: page => {}, allowing you to access and reassign the updated property.

Please or to participate in this conversation.