#Validation errors not showing when using Inertia.post

1 messages · Page 1 of 1 (latest)

finite wasp
#

I remember having this issue. As I recall you need to use _method: 'post' and for image you should process using FormData

pliant trout
#

@rancid plume Please only post once, first warning :p

finite wasp
#

I don't remember in newer versions of Inertia handle images with FormData

rancid plume
#

Ok I'll try _method: 'post,

#

not working I really have to use _method: put

#

offical docs

#

the problem really is that validation when updating is not showing in view

#

WHEN using Inertia.post _method: put

rancid plume
upbeat flare
rancid plume
#

I'll keep that in mind

upbeat flare
#

But yeah, this has nothing to do with method spoofing. You're using two entirely different approaches, Inertia.post() and form.put(). The first one won't have any effect on the form object, so errors etc won't be updated.

#

You should use form.post() and add the method spoofing as the form data

rancid plume
#

Like this?

upbeat flare
#

No

#
const form = useForm({
  _method: 'put',
  name: '',
});

form.post('url', options)

Or you'd have to use transform to add the field before submitting

rancid plume
#

is useForm() only available for vue3? I'm using vue2

upbeat flare
#

No, not yet. But it's the same as creating a form with this.$inertia.form. Though, it's limited to options api

rancid plume
#

Ok so here's what I did so far. Validation error is still not displaying in view