mercredi 30 août 2017

Laravel repeated select list validation

I have form that has a repeated select list like the following:

<select class="form-control set-25" name="equipments[:selectName:-1]">...
<select class="form-control set-24" name="equipments[:selectName:-2]">....
<select class="form-control set-8" name="equipments[:selectName:-3]">....

I want to validate each one of those lists.

public function installCavitySave(Request $request)
    {

        $this->validate(request(), ['equipments.*' => 'required']);
       dd(request());
    }

However, the rule does not work. When I tried $this->validate(request(), ['equipments' => 'required']) It works only if there is no any select option values selected but if one of them is selected the validation allow others to be null.

I need the validation to validate every select list named equipments[x] where x is any key supplied to the elements name attribute.



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

Aucun commentaire:

Enregistrer un commentaire