dimanche 8 juillet 2018

Laravel Validation Required_if

In my form, I have a marking scheme, and a criteria for marking scheme.

 <div class="form-group">
                        
                        
                    </div>
                    <div class="form-group">
                        <br>
                        
                        
                        
                        
                    <!--<input type="checkbox" value="punctuation" name="criteria">Punctuation &nbsp;&nbsp;&nbsp;
                        <input type="checkbox" value="spacing" name="criteria">Spacing-->
                    </div>

In my request, I have the following:

    'criteria'      => 'required_if:marking_scheme,==,strict'

What I would like is if I select strict, I have to select minimally a checkbox, but if I select relax, I cannot have a checkbox ticked.

Now it works in that if it's strict and no checkbox is ticked, it runs a message error by the request. But if it's relax and I check a box, it still runs without problem when it should throw an error.

I cannot figure what I am doing wrong and would appreciate any help!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire