The imageable/documentable object is always the object the form builder is based on; since we're already passing the form builder, we don't have to pass the object as well. The only exception are the poll answers. In this case, we're passing a new answer as the object. That's OK; the same hack that we're using to send the data to the answer URL without displaying existing attachments causes the form to keep working the same way.
27 lines
1.2 KiB
Plaintext
27 lines
1.2 KiB
Plaintext
<% documentable = f.object %>
|
|
|
|
<div class="documents-list">
|
|
<%= f.label :documents, t("documents.form.title") %>
|
|
<p class="help-text"><%= documentables_note(documentable) %></p>
|
|
|
|
<div id="nested-documents" data-max-documents-allowed="<%= documentable.class.max_documents_allowed %>">
|
|
<%= f.fields_for :documents do |documents_builder| %>
|
|
<%= render Documents::FieldsComponent.new(documents_builder) %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= link_to_add_association t("documents.form.add_new_document"), f, :documents,
|
|
partial: "documents/document_fields",
|
|
id: "new_document_link",
|
|
class: "button upload-document
|
|
#{"hide" if max_documents_allowed?(documentable)}",
|
|
data: {
|
|
association_insertion_node: "#nested-documents",
|
|
association_insertion_method: "append"
|
|
} %>
|
|
|
|
<div id="max-documents-notice" class="max-documents-notice callout primary text-center <%= "hide" unless max_documents_allowed?(documentable) %>">
|
|
<%= sanitize(t("documents.max_documents_allowed_reached")) %>
|
|
</div>
|
|
</div>
|