mkhairi/materialize-sass

Question for File Input section

tienshunlo opened this issue · 1 comments

I uploaded a file in the File Input section, and actually saw the name of it showed in the file-path-wrapper div. But when I upload a file in my rails project, I saw nothing in that div. Anything I need to do to make it happen?

Thanks for any help.

<form action="#">
    <div class="file-field input-field">
      <div class="btn">
        <span>File</span>
        <input type="file">
      </div>
      <div class="file-path-wrapper">
        <input class="file-path validate" type="text">
      </div>
    </div>
  </form>
        

Hi there!
I'm using Rails 5.0.2 and this is the way I use file component. Actually I don't have any problem with this.

<div class="file-field input-field col s12">
    <div class="btn-flat img-button">
        <span><i class="material-icons">cloud_upload</i></span>
        <%= f.file_field :image, {accept: "image/x-png, image/jpeg"} %>
    </div>
    <div class="file-path-wrapper">
        <%= text_field_tag nil, (f.object.image.original_filename unless f.object.image.blank?), {id: nil, class: 'file-path validate', placeholder: 'Your filename here!'} %>
    </div>
</div>

Maybe your problem have to see with the value attribute for the input in file-path-wrapper.
I used Ruby code to see what I have before rendering the view in order to have a better reference.
I hope it could be useful.