jeudi 17 octobre 2019

Laravel Validation: Field showing required error even has value

I have a field automatically generated depending on the chosen value of a drop down option. Now I'm having problem in my validation for it is showing error even though my fields has values. I did it this way:

@for($num = 0; $num < 10); $num++)
    <input type="text" class="form-control guest_name" name="last_name[]" id="last_name" placeholder="lastname" value="">
    <div class="form-group h-20px">
        @if ($errors->has('last_name.'.$num ))
            <p class="text-danger"></p>
        @endif
    </div>
@endfor

validation.php

$val = ['required'];
for($i=0; $i < count($this->request->get('last_name')); $i++){
    $rules['last_name.'.$i] = $val;
}
return $rules

So if I have two lastname fields, even though the fields have value, they are still showing error saying last name field is required. Where should I adjust on my validation? Any thoughts on this?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2qmv5F1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire