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

laravelmark's avatar

Variable in vue v-model

I am using a textarea field in a form and if I insert a value from the database into it (using laravel 10 and inertia) it is not displayed. However, it is displayed in any other place. It is obvious that the value conflicts with in the v-model

... let form = reactive({ header: '', }); ... ... {{ article.header }} ... At the same time, I cannot set the default value in the vmodel like this data() { return { form.header: article.header, } The syntax of form.header is incorrect, and article.header is not defined. .

let form = reactive({ header: article.header, }); article.header is not defined too

How could I pass the value of the variable to the texarea with v-model field

0 likes
1 reply
dcx's avatar

The on the text area v-model the form value, like v-model=form.header when you initialize the form header set the value to props.header...that's the general direction I've used in the past without issue.

Example with Inertia:

import { useForm } from "@inertiajs/vue3";

const props = defineProps({
header: String
});

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

/*in your text area add this  v-model="form.header"*/

Then your initial variable is there but can also be edited and submitted in the form...

Please or to participate in this conversation.