Fix invalid HTML in document/image fields labels

These labels weren't associated with any fields, which is invalid HTML.
We're using a legend inside a fieldset instead, which is the natural way
to group form fields together.
This commit is contained in:
Javi Martín
2021-07-12 00:31:40 +02:00
parent c9903f36cc
commit 394a94cbff
2 changed files with 25 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
<div class="documents-list"> <fieldset class="documents-list">
<%= f.label :documents, t("documents.form.title") %> <legend><%= t("documents.form.title") %></legend>
<p class="help-text"><%= note %></p> <p class="help-text"><%= note %></p>
<div id="nested-documents" data-max-documents-allowed="<%= max_documents_allowed %>"> <div id="nested-documents" data-max-documents-allowed="<%= max_documents_allowed %>">
@@ -21,4 +21,4 @@
<div id="max-documents-notice" class="max-documents-notice callout primary text-center <%= "hide" unless max_documents_allowed? %>"> <div id="max-documents-notice" class="max-documents-notice callout primary text-center <%= "hide" unless max_documents_allowed? %>">
<%= sanitize(t("documents.max_documents_allowed_reached")) %> <%= sanitize(t("documents.max_documents_allowed_reached")) %>
</div> </div>
</div> </fieldset>

View File

@@ -1,22 +1,24 @@
<%= f.label image_fields, t("images.form.title") %> <fieldset>
<p class="help-text"><%= note %></p> <legend><%= t("images.form.title") %></legend>
<p class="help-text"><%= note %></p>
<div id="nested-image"> <div id="nested-image">
<%= f.fields_for image_fields do |image_builder| %> <%= f.fields_for image_fields do |image_builder| %>
<%= render Images::FieldsComponent.new(image_builder, imageable: imageable) %> <%= render Images::FieldsComponent.new(image_builder, imageable: imageable) %>
<% end %> <% end %>
</div> </div>
<%= link_to_add_association t("images.form.add_new_image"), f, image_fields, <%= link_to_add_association t("images.form.add_new_image"), f, image_fields,
force_non_association_create: true, force_non_association_create: true,
partial: "images/image_fields", partial: "images/image_fields",
id: "new_image_link", id: "new_image_link",
class: "button upload-image class: "button upload-image
#{"hide" if image_fields == :image && imageable.image.present?}", #{"hide" if image_fields == :image && imageable.image.present?}",
render_options: { render_options: {
locals: { imageable: imageable } locals: { imageable: imageable }
}, },
data: { data: {
association_insertion_node: "#nested-image", association_insertion_node: "#nested-image",
association_insertion_method: "append" association_insertion_method: "append"
} %> } %>
</fieldset>