-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Twig] Form - Bootstrap 4 layout - custom-file-input - not able to see which file are selected in a input file type #27477
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
Comments
Still seems to be an issue here. I need to add css to make something show up. .custom-file-label { opacity: 0; } |
Same here, all people in my class can't see the file name when selected. |
The problem is not the class, but that a custom form field doesn't automatically update if the underlying form field changes. Please see the discussion here for a) how to fix the described issue and b) maybe discuss whether we should maybe add this JS inline in the form theme. |
I am closing here as the behaviour is consistent with the Bootstrap behaviour. |
I'm adding a comment on this closed issue cos the beheviour is in fact not consistent with the Bootstrap. |
@Janest Even on the documentation page that you linked to you can find an example using |
@xabbuh Indeed, and it doesn't display the chosen file name, it's below this explanation :
It's also writen on that page, in the section I mentioned :
And the example below displays the chosen file name as expected. |
You might use bs-custom-file-input plugin to set placeholders automatically when the file was chosen. Just add the following script to the symfony project: Then init the script (base.twig.html template):
Plugin: https://www.npmjs.com/package/bs-custom-file-input Boostrap documentation reference: https://getbootstrap.com/docs/4.4/components/forms/#file-browser |
Symfony version(s) affected: 4.1
Description
When rendering a
<input type="file">
withbootstrap_4_layout.html.twig
enabled, it gives the input a classcustom-file-input
and the label a classcustom-file-label
. The CSS for this, do that its not able to see which file are selected, as in a normal<input type="file">
No selected file
And with a file selected
Now if you in the FormType set the label to false on the element, also I have added a placeholder with ['attr' => ['placeholder' => 'Choose file']
(Yes totally blank, but still able to select a file by clicking in the empty area, but still blank after selected a file)
How to reproduce
Create a form type with type
Symfony\Component\Form\Extension\Core\Type\FileType
Add the bootstrap 4 css to twig
https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css
Add
form_themes: ['bootstrap_4_layout.html.twig']
toconfig/packages/twig
Create a controller with your form type
Or just clone
https://github.com/lsv/twig_bootstrap4_filetype
Possible Solution
The
custom-file-label
andcustom-file-input
classes should be removed, or reworked.With the following code
This will be the result
The text was updated successfully, but these errors were encountered: