laravel提交表单的时候,如果input type='text'
,下面的代码可以正常显示验证信息:
<div class="form-group row">
<label for="username" class="col-2 col-form-label">username:</label>
<div class="col-10">
<input id="username" name="username" class="form-control {{ $errors->has('username') ? ' is-invalid' : '' }}" type="text" value="{{ old('username') }}">
@if ($errors->has('username'))
<div class="invalid-feedback">{{ $errors->first('username') }}</div>
@endif
</div>
</div>
问题:
如果input
type='file'`, 下面代码不能显示验证信息,应该怎么写才可以?
<div class="form-group row">
<label for="photo" class="col-2 col-form-label">photo:</label>
<div class="col-10">
<input type="file" id="photo" name="photo">
@if ($errors->has('photo'))
<div class="invalid-feedback">{{ $errors->first('photo') }}</div>
@endif
</div>
</div>
要看你的photo的验证规则是怎么写的,如果没有错误,当然就不会显示