Set the existing/current value in the form like this:
useForm({
field: 'value',
another_field: 123,
});
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm having a problem assigning the input "value" parameter to the useForm variable in Inertiajs. Here is the scenario 1- I have a form with 6 fields, all of which are of text type. 2- There is a hidden input field which holds the user ID. (The user ID is coming from a parent component using props along with other data) 3- I will pass this data to controller for further processing.
Problem As I'm using Inertiajs so form values are reactive but problem is how can pass that hidden field in it?
Form Code
<input type="text"
name="hobbie"
placeholder="Enter hobbies"
v-model="form.hobbie"
required
>
<br> <br>
<input type="text"
name="physical_health"
placeholder="Enter Physical Health"
v-model="form.physical_health"
required
>
<br> <br>
<input
type="text"
name="education"
placeholder="Enter Education"
v-model="form.education"
required
>
<br> <br>
<input
type="text"
name="mental_health"
placeholder="Enter Mental Health"
v-model="form.mental_health"
required
>
<br><br>
<input
type="text"
name="behaviour"
placeholder="Enter Behaviours"
v-model="form.behaviour"
required
>
<br><br>
<input
type="text"
name="self_care"
placeholder="Enter Self Care"
v-model="form.self_care"
required
>
<br><br>
<input
type="text"
name="life_skill"
placeholder="Enter Life Skills"
v-model="form.life_skill"
required
>
<br><br>
<input type="submit" value="Add Station" class="submit"> <br><br>
</form>
Vue Script Code
<script setup>
import { useForm } from '@inertiajs/inertia-vue3';
const props = defineProps({ sData: String });
const form = useForm({ childID:"", hobbie: '', physical_health: '', education:'', mental_health:'', behaviour: '', self_care: '', life_skill: '', }); const submit = () => { form.post(route('add_station_1'), { onFinish: () => form.reset(), }); };
PS** I have tried to assign value like this "child_id: sData[0].ChildID" but it's not working as well.
Please or to participate in this conversation.