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

la-bas's avatar

Default form data passed by props

I want to populate a form in a modal with some default data before I open it. So I pass the values via props to the form data. This works fine the first time I open the modal, but the next time the props is updated the form data will not be updated. Obviously since setup is not run every time the props are uptaded. (Yes. I want the props to override any previously entered form data, when they change.)

I can solve this problem by actively *watch() the props, but I get a feeling that I am dealing with the problem the wrong way?

Simplified code:

<script setup>
import { useForm } from '@inertiajs/inertia-vue3'

    const props = defineProps({
	    project: Object
    });

    const form = useForm({
	    project: props.project
    });

</script>
<template>
    <input type="text" v-model="form.project.name" id="project_name" /><br />
    <p>{{ project.name }}</p>

</template>
0 likes
0 replies

Please or to participate in this conversation.