diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 40613b044..87b04c317 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -6,8 +6,7 @@ <%= f.text_area :body, id: "comment-body-#{css_id}", maxlength: Comment.body_max_length, - label: leave_comment_text(commentable), - label_options: { for: "comment-body-#{css_id}" } %> + label: leave_comment_text(commentable) %> <%= f.hidden_field :commentable_type, value: commentable.class.name %> <%= f.hidden_field :commentable_id, value: commentable.id %> @@ -20,16 +19,14 @@
<%= f.check_box :as_moderator, label: t("comments.form.comment_as_moderator"), - id: "comment-as-moderator-#{css_id}", - label_options: { for: "comment-as-moderator-#{css_id}" } %> + id: "comment-as-moderator-#{css_id}" %>
<% end %> <% if can? :comment_as_administrator, commentable %>
<%= f.check_box :as_administrator, label: t("comments.form.comment_as_admin"), - id: "comment-as-administrator-#{css_id}", - label_options: { for: "comment-as-administrator-#{css_id}" } %> + id: "comment-as-administrator-#{css_id}" %>
<% end %> diff --git a/app/views/legislation/annotations/_comments_box.html.erb b/app/views/legislation/annotations/_comments_box.html.erb index 7340f7e04..b9e8eea70 100644 --- a/app/views/legislation/annotations/_comments_box.html.erb +++ b/app/views/legislation/annotations/_comments_box.html.erb @@ -25,8 +25,11 @@ <% css_id = parent_or_commentable_dom_id(nil, annotation) %> diff --git a/app/views/tracking/progress_bars/_form.html.erb b/app/views/tracking/progress_bars/_form.html.erb index 4a66107d3..7606b17e8 100644 --- a/app/views/tracking/progress_bars/_form.html.erb +++ b/app/views/tracking/progress_bars/_form.html.erb @@ -19,8 +19,10 @@ <% progress_options = { min: ProgressBar::RANGE.min, max: ProgressBar::RANGE.max, step: 1 } %>
+ <%= f.label :percentage %> <%= f.text_field :percentage, { type: :range, id: "percentage_range", + label: false, class: "column" }.merge(progress_options) %>
diff --git a/app/views/valuation/budget_investments/_dossier_form.html.erb b/app/views/valuation/budget_investments/_dossier_form.html.erb index 5f601b18b..b7fea5574 100644 --- a/app/views/valuation/budget_investments/_dossier_form.html.erb +++ b/app/views/valuation/budget_investments/_dossier_form.html.erb @@ -77,7 +77,6 @@
<%= f.check_box :valuation_finished, label: t("valuation.budget_investments.edit.valuation_finished"), - label_options: { for: "js-investment-report-alert" }, id: "js-investment-report-alert", "data-alert": t("valuation.budget_investments.edit.valuation_finished_alert"), "data-not-feasible-alert": t("valuation.budget_investments.edit.not_feasible_alert") %> diff --git a/lib/consul_form_builder.rb b/lib/consul_form_builder.rb index 205339422..b6064fbe2 100644 --- a/lib/consul_form_builder.rb +++ b/lib/consul_form_builder.rb @@ -9,7 +9,7 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder %i[text_field text_area cktext_area number_field password_field email_field].each do |field| define_method field do |attribute, options = {}| - label_with_hint(attribute, options) + + label_with_hint(attribute, options.merge(label_options: label_options_for(options))) + super(attribute, options.merge( label: false, hint: false, aria: { describedby: help_text_id(attribute, options) } @@ -21,7 +21,7 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder if options[:label] != false label = content_tag(:span, label_text(object, attribute, options[:label]), class: "checkbox") - super(attribute, options.merge(label: label)) + super(attribute, options.merge(label: label, label_options: label_options_for(options))) else super end @@ -42,6 +42,16 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder end end + def label_options_for(options) + label_options = options[:label_options] || {} + + if options[:id] + { for: options[:id] }.merge(label_options) + else + label_options + end + end + def help_text(attribute, options) if options[:hint] content_tag :span, options[:hint], class: "help-text", id: help_text_id(attribute, options)