marufalom
390
2
Vue

Laravel array validation with vue components

Posted 9 months ago by marufalom

I have a large form with array of data. My html looks like this

<input placeholder="order number" name="order_number[]" type="text" :value="data.order_number" class="form-control custom-input ">
 
<form-error v-if="errorList.order_number" :allerror="errorList.order_number"></form-error>

I have a child vue component which receive laravel validation error messages as props.

Vue.component('formError', {
    props: ['allerror'],
    template: '<span class="text-danger">{{ allerror[0] }}</span>'
})

This works fine for single entry. When I am trying to validate array of input fields it doesn't work.

I got this from messages from laravel:

order.0
:
["The order.0 field is required."]
order.2
:
["The order.2 field is required."]
order.3
:
["The order.3 field is required."]

How can I loop through the actual errors in field?

Thanks

Please sign in or create an account to participate in this conversation.