Using simple_form_for, Bootstrap and Rails 3. In a form:
<%= f.input :upload, label: 'PDF file:' , input_html: {accept: ('application/pdf') } %>
I don't know how I'd style this so that the "choose file" button can have a different class ('btn btn-primary').
Additionally, when using with Bootstrap at least, its severely misaligned by default. See attached image.
Finally, how do I redefine the text from "No file chosen" to "Chose file" when there isn't one added yet, and show the file name when there is one.
No JS required, just plain css
scss
html / slim
I recommend using compass for cross browser compatibility
As @rafaelfranca said you can't style
file
input but you can add your own button which will be clicking your hidden original button. See example here http://jsfiddle.net/rUdf2/6/If you are using Bootstrap, Simple Forms, Jasny, and ReFile, this post may be of interest to you refile simple_form undefined method attachment_field
This is how I do it:
Add a button to trigger the file browse dialog
In your JS (Coffee w/ jQuery shown), pass the click from the display button onto the real file input and when they select a file drop the file name in the display text field (I drop the path so that I don't see C:\FakePath....)
I ran across and am using Jasny's extension to Bootstrap 3. It seems to work well so far.
No fancy shiz required:
HTML:
JS:
CAUTION: The three form elements in question MUST be siblings of each other (.image-file-chosen, .image-file-button, .image-file)