Level 63
Have you checked the content of you item variable ?
What do you see when you log this variable in the console ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to create a crud all on the same page using dialogs/modals for creating and editing an item. I'm using inertia's form helper useForm https://inertiajs.com/forms#form-helper.
This is my code so far but the form never gets replaced with the values I want.
<script setup>
import {Head, useForm} from '@inertiajs/inertia-vue3';
import {Inertia} from '@inertiajs/inertia';
import {reactive, watch, ref, computed} from "vue";
//data
let form = useForm({
username: null,
email: null,
password: null,
password_confirmation: null,
date_of_birth: null,
role_id: null
})
//methods
const create = () => {
show_form.value = true;
}
const edit = (item) => {
console.log(item);
form = useForm(item);
// form.value= useForm(item);
// form.id = item.id;
// form.username = item.username;
// form.email = item.email;
// form.date_of_birth = item.date_of_birth;
// form.role_id = item.role.id;
show_form.value = true;
console.log(form);
}
I tried those ways in the edit method but there isn't any changes, what am I doing wrong?
Please or to participate in this conversation.