Add accept HTML attribute to documents form file input.
This commit is contained in:
@@ -16,6 +16,12 @@ module DocumentablesHelper
|
||||
documentable.class.accepted_content_types
|
||||
end
|
||||
|
||||
def accepted_content_types_extensions(documentable)
|
||||
documentable.class.accepted_content_types
|
||||
.collect{ |content_type| ".#{content_type.split("/").last}" }
|
||||
.join(",")
|
||||
end
|
||||
|
||||
def humanized_accepted_content_types(documentable)
|
||||
documentable.class.accepted_content_types
|
||||
.collect{ |content_type| content_type.split("/").last }
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
<div class="small-12 column">
|
||||
<div class="file-name">
|
||||
<%= f.file_field :attachment, label: false, class: 'show-for-sr' %>
|
||||
<%= f.file_field :attachment,
|
||||
accept: accepted_content_types_extensions(@document.documentable),
|
||||
label: false, class: 'show-for-sr' %>
|
||||
<%= f.label :attachment, t("documents.form.attachment_label"), class: 'button hollow' %>
|
||||
<p><%= document_attachment_file_name(@document) %></p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user