leaveme_alone
leaveme_alone

Reputation: 686

How to do hidden filed validation Laravel?

I am working in a module with Laravel and Vuejs where some fields are by default hidden. And based on user action those hidden fields are unhide and showing as form input field. These hidden fields I need to do validate when user submit the form. Following is my Json Object for creating hidden input field:

"customer_order_details":{
    "payment_by": null
}

And Html input field in Vuejs is following:

<input v-model="customer_order_details.payment_by" class ="form-control" placeholder="Payment By">

And validation rules in Request controller is:

$rules = [
    'payment_by' => 'sometimes|required',
];

In the above configuration whenever I submit the form whatever payment_by field hide/unhide always show validation error. But I need to show validation error only when payment_by filed is unhidden.

Upvotes: 0

Views: 921

Answers (0)

Related Questions