mardi 29 mars 2022

Laravel validation rule based on other fields value

I have this radio button

<input class="form-check-input" type="radio" name="discount" value="Yes">
<input class="form-check-input" type="radio" name="discount" value="No" checked>

and this hidden field

 <input type="hidden" name="discount_valid" value="true">

by default this hidden field is true

Now when i'm trying to validate if discount_valid is true then it should submit the form this code is working but i want to add another condition, if discount is No then it should submit the form irrespective of whether discount value is true or false. If discount is Yes and discount_valid is false then form should not submit.

$validator = Validator::make($request->all(), [
            'discount_valid'=>'in:true',
]);                           

                                         


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

Aucun commentaire:

Enregistrer un commentaire