我有一个表单。提交表单后,如果有一些错误,那么它会重定向到同一页面并预先填充用户提交的数据。我有这种形式的3 checkbox
字段。假设用户只检查了first checkbox
并提交了表单。所以如果表单有一些错误,它会重定向到同一页面,但是问题是它再次在这里重定向,然后all the checkboxes got selected instead of only the 1st one
。Laravel复选框输入旧的不能正常工作
<div class="form-group">
<label>Hobbies: <span><em>{{$errors->first('hobbies')}}</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>
有你输入::旧的(? – rahulsm
没有。我没有检查我使用laravel 5.4 –
其中laravel的版本,您正在使用? – rahulsm