Added file form helper

This commit is contained in:
Deon George 2022-08-19 15:11:09 +10:00
parent d494400e7e
commit e3ebef90d9

View File

@ -0,0 +1,39 @@
<div class="form-group">
<label for="{{ $id }}">{{ $label }}</label>
<div class="input-group has-validation">
@empty($icon)
@else
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa-fw {{ $icon }}"></i></span>
</div>
@endempty()
<div class="custom-file">
<input type="file" class="custom-file-input @error($id) is-invalid @enderror" id="{{ $id }}" name="{{ $name ?? $id}}">
<label class="custom-file-label input-group-text" for="{{ $id }}">Choose file</label>
</div>
{{--
<div class="input-group-append">
<button type="submit" class="input-group-text btn btn-success" id="">Upload</button>
</div>
--}}
<span class="invalid-feedback @error($id) d-block @enderror" role="alert">
@error($id)
{{ $message }}
@enderror
</span>
</div>
</div>
@section('page-scripts')
<script>
$(document).ready(function() {
$('#{{ $id }}').on('change',function(){
//get the file name
var fileName = $(this).val();
//replace the "Choose a file" label
$(this).next('.custom-file-label').html(fileName);
})
});
</script>
@append