leenooks/resources/components/form/file.blade.php

17 lines
635 B
PHP
Raw Normal View History

<x-leenooks::form.base {{ $attributes }}>
<input type="file" class="form-control {{ $classes ?? ''}}@error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>
</x-leenooks::form.base>
{{ $slot }}
@section('page-scripts')
<script>
$(document).ready(function() {
$('#{{ $id ?? $name }}').on('change',function(){
//get the file name
var fileName = $(this).val();
//replace the "Choose a file" label
$(this).parent().next('.input-helper').html(fileName);
})
});
</script>
@append