Fix duplicate HTML ID in document fields

Using `dom_id` means generating `new_document` as ID for new documents.
Since there might be more than one new document in the form, that means
duplicate IDs, which is invalid HTML.

Even though this issue doesn't affect image fields (because we don't
have many images on the same form), we're removing the ID there as well
for consistency.
This commit is contained in:
Javi Martín
2021-07-12 01:15:40 +02:00
parent 394a94cbff
commit 8cdee167f8
3 changed files with 3 additions and 3 deletions

View File

@@ -1,4 +1,4 @@
<div id="<%= dom_id(document) %>" class="document direct-upload document-fields nested-fields">
<div class="document direct-upload document-fields nested-fields">
<%= f.hidden_field :id %>
<%= f.hidden_field :user_id, value: current_user.id %>
<%= f.hidden_field :cached_attachment %>

View File

@@ -1,4 +1,4 @@
<div id="<%= dom_id(image) %>" class="image direct-upload nested-fields">
<div class="image direct-upload nested-fields">
<%= f.hidden_field :id %>
<%= f.hidden_field :user_id, value: current_user.id %>
<%= f.hidden_field :cached_attachment %>

View File

@@ -320,7 +320,7 @@ end
def documentable_attach_new_file(path, success = true)
click_link "Add new document"
document = all("#new_document").last
document = all(".document").last
document_input = document.find("input[type=file]", visible: :hidden)
attach_file(document_input[:id], path, make_visible: true)