Simplify generating form fields with labels

Instead of generating the label and then a field without a label, we can
directly generate a field with a label.
This commit is contained in:
Javi Martín
2019-10-02 23:27:48 +02:00
parent 42dbbf5507
commit 3ea9f3cecf
31 changed files with 109 additions and 141 deletions

View File

@@ -33,18 +33,15 @@ module DocumentsHelper
def render_attachment(builder, document)
klass = document.persisted? || document.cached_attachment.present? ? " hide" : ""
html = builder.label :attachment,
t("documents.form.attachment_label"),
class: "button hollow #{klass}"
html += builder.file_field :attachment,
label: false,
accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: "js-document-attachment",
data: {
url: document_direct_upload_url(document),
nested_document: true
}
html
builder.file_field :attachment,
label: t("documents.form.attachment_label"),
label_options: { class: "button hollow #{klass}" },
accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: "js-document-attachment",
data: {
url: document_direct_upload_url(document),
nested_document: true
}
end
def document_direct_upload_url(document)