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

hjortur17's avatar

$setup.form.errors.user is undefined

Hi, I'm trying to use Inertia useForm validation but I get error on because it's trying to read the object when it's empty. Any idea why this is happening? I'm looking for the error like this:

<small
	v-if="form.errors.user.name.first"
	v-text="form.errors.user.name.first"
	class="text-red-600"
></small>
0 likes
1 reply
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Try this (optional chaining)

v-if="form.errors.user?.name?.first" 
1 like

Please or to participate in this conversation.