I have a form. After submission of the form if it has some error then it redirects to the same page and pre-populate the data that user submitted. I have 3 checkbox
fields in that form. Suppose user has checked only the first checkbox
and submitted the form. So if the form has some error it will redirect to the same page, but the problem is when it redirects here again then all the checkboxes got selected instead of only the 1st one
.
<div class="form-group">
<label>Hobbies: <span><em></em></span></label>
<input type="checkbox" name="hobbies[]" value="Cricket" @if (is_array(old('hobbies'))) && (in_array('Cricket', old('hobbies'))) checked @endif> Cricket
<input type="checkbox" name="hobbies[]" value="Football" @if (is_array(old('hobbies'))) && (in_array('Football', old('hobbies'))) checked @endif> Football
<input type="checkbox" name="hobbies[]" value="Badminton" @if (is_array(old('hobbies'))) && (in_array('Badminton', old('hobbies'))) checked @endif> Badminton
</div>
Aucun commentaire:
Enregistrer un commentaire