Skip to content

Bootstrap 4 Form Theme : Added tip to get <input type="file"> displaying the selected file to upload #13727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions form/bootstrap4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ Checkboxes and Radios
For a checkbox/radio field, calling ``form_label()`` doesn't render anything.
Due to Bootstrap internals, the label is already rendered by ``form_widget()``.

File inputs
-----------

Files input are rendered using the Bootstrap "custom-file" class.

Due to Bootstrap internals, the rendered field does not display the selected filename.
To fix that missing display, you can use the "`bs-custom-file-input`_" plugin (vanilla javascript), as recommended by `Bootstrap Forms documentation`_.

Accessibility
-------------

Expand Down Expand Up @@ -126,6 +134,8 @@ Symfony Form ``RadioType`` and ``CheckboxType`` by adding some classes to the la
{{ form_row(form.myCheckbox, {label_attr: {class: 'switch-custom'} }) }}

.. _`WCAG 2.0 standard`: https://www.w3.org/TR/WCAG20/
.. _`bs-custom-file-input`: https://www.npmjs.com/package/bs-custom-file-input
.. _`Bootstrap Forms documentation`: https://getbootstrap.com/docs/4.4/components/forms/#file-browser
.. _`custom forms`: https://getbootstrap.com/docs/4.4/components/forms/#custom-forms
.. _`custom radio`: https://getbootstrap.com/docs/4.4/components/forms/#radios
.. _`custom checkbox`: https://getbootstrap.com/docs/4.4/components/forms/#checkboxes
Expand Down