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

17 lines
582 B
PHP
Raw Normal View History

<x-leenooks::form.base {{ $attributes }}>
<input type="file" class="form-control {{ $classes ?? ''}}@error($name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @readonly(isset($readonly)) @required(isset($required))>
</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