Symfony 4 表单文件上传字段不显示带有 Bootstrap 4 主题的选定文件名
Symfony 4 Form file upload field does not show selected filename with Bootstrap 4 theme
使用 Symfony 4.2.5,我制作了一个带有 FileType 文件上传字段的表单,如 upload file. I used the Bootstrap 4 theme as described at form_themes and bootstrap4 所述。
config/packages/twig.yaml 包含:
twig:
form_themes: ['bootstrap_4_horizontal_layout.html.twig']
当我加载网页和 select 要上传的文件时,FileType 字段显示一个空白文件名:
我发现此问题记录在 Symfony issue 27477 中。
在使用 Symfony 的 Bootstrap 4 主题时,有没有办法让 Symfony 4 文件类型字段显示 selected 文件名?
要使表单文件输入字段显示所选文件名,Bootstrap 4.3 documentation recommends using the JavaScript library bs-custom-file-input。
将此 JavaScript 添加到您的网页:
<script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.min.js"></script>
<script>
$(document).ready(function () {
bsCustomFileInput.init()
})
</script>
使用 Symfony 4.2.5,我制作了一个带有 FileType 文件上传字段的表单,如 upload file. I used the Bootstrap 4 theme as described at form_themes and bootstrap4 所述。
config/packages/twig.yaml 包含:
twig:
form_themes: ['bootstrap_4_horizontal_layout.html.twig']
当我加载网页和 select 要上传的文件时,FileType 字段显示一个空白文件名:
我发现此问题记录在 Symfony issue 27477 中。
在使用 Symfony 的 Bootstrap 4 主题时,有没有办法让 Symfony 4 文件类型字段显示 selected 文件名?
要使表单文件输入字段显示所选文件名,Bootstrap 4.3 documentation recommends using the JavaScript library bs-custom-file-input。
将此 JavaScript 添加到您的网页:
<script src="https://cdn.jsdelivr.net/npm/bs-custom-file-input/dist/bs-custom-file-input.min.js"></script>
<script>
$(document).ready(function () {
bsCustomFileInput.init()
})
</script>