diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb
index b1fda5247..90ac292d5 100644
--- a/app/views/account/show.html.erb
+++ b/app/views/account/show.html.erb
@@ -32,82 +32,40 @@
- <%= f.label :public_activity do %>
- <%= f.check_box :public_activity, title: t("account.show.public_activity_label"), label: false %>
-
- <%= t("account.show.public_activity_label") %>
-
- <% end %>
+ <%= f.check_box :public_activity, label: t("account.show.public_activity_label") %>
- <%= f.label :public_interests do %>
- <%= f.check_box :public_interests, title: t("account.show.public_interests_label"), label: false %>
-
- <%= t("account.show.public_interests_label") %>
-
- <% end %>
+ <%= f.check_box :public_interests, label: t("account.show.public_interests_label") %>
<% if @account.email.present? %>
<%= t("account.show.notifications") %>
- <%= f.label :email_on_comment do %>
- <%= f.check_box :email_on_comment, title: t("account.show.email_on_comment_label"), label: false %>
-
- <%= t("account.show.email_on_comment_label") %>
-
- <% end %>
+ <%= f.check_box :email_on_comment, label: t("account.show.email_on_comment_label") %>
- <%= f.label :email_on_comment_reply do %>
- <%= f.check_box :email_on_comment_reply, title: t("account.show.email_on_comment_reply_label"), label: false %>
-
- <%= t("account.show.email_on_comment_reply_label") %>
-
- <% end %>
+ <%= f.check_box :email_on_comment_reply, label: t("account.show.email_on_comment_reply_label") %>
- <%= f.label :email_newsletter_subscribed do %>
- <%= f.check_box :newsletter, title: t("account.show.subscription_to_website_newsletter_label"), label: false %>
-
- <%= t("account.show.subscription_to_website_newsletter_label") %>
-
- <% end %>
+ <%= f.check_box :newsletter, label: t("account.show.subscription_to_website_newsletter_label") %>
- <%= f.label :email_digest do %>
- <%= f.check_box :email_digest, title: t("account.show.email_digest_label"), label: false %>
-
- <%= t("account.show.email_digest_label") %>
-
- <% end %>
+ <%= f.check_box :email_digest, label: t("account.show.email_digest_label") %>
- <%= f.label :email_on_direct_message do %>
- <%= f.check_box :email_on_direct_message, title: t("account.show.email_on_direct_message_label"), label: false %>
-
- <%= t("account.show.email_on_direct_message_label") %>
-
- <% end %>
+ <%= f.check_box :email_on_direct_message, label: t("account.show.email_on_direct_message_label") %>
<% end %>
<% if @account.official_level == 1 %>
- <%= f.label :official_position_badge do %>
- <%= f.check_box :official_position_badge,
- title: t("account.show.official_position_badge_label"),
- label: false %>
-
- <%= t("account.show.official_position_badge_label") %>
-
- <% end %>
+ <%= f.check_box :official_position_badge, label: t("account.show.official_position_badge_label") %>
<% end %>
@@ -116,23 +74,13 @@
<% if feature?("user.recommendations_on_debates") %>
- <%= f.label :recommended_debates do %>
- <%= f.check_box :recommended_debates, title: t("account.show.show_debates_recommendations"), label: false %>
-
- <%= t("account.show.show_debates_recommendations") %>
-
- <% end %>
+ <%= f.check_box :recommended_debates, label: t("account.show.show_debates_recommendations") %>
<% end %>
<% if feature?("user.recommendations_on_proposals") %>
- <%= f.label :recommended_proposals do %>
- <%= f.check_box :recommended_proposals, title: t("account.show.show_proposals_recommendations"), label: false %>
-
- <%= t("account.show.show_proposals_recommendations") %>
-
- <% end %>
+ <%= f.check_box :recommended_proposals, label: t("account.show.show_proposals_recommendations") %>
<% end %>
<% end %>
diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb
index 851b43789..f8a51add9 100644
--- a/app/views/admin/budget_investments/edit.html.erb
+++ b/app/views/admin/budget_investments/edit.html.erb
@@ -105,18 +105,16 @@
<% if @investment.incompatible? || @investment.winner? %>
<%= t("admin.budget_investments.edit.compatibility") %>
- <%= f.label :incompatible do %>
- <%= f.check_box :incompatible, title: t("admin.budget_investments.edit.compatibility"), label: false %>
- <%= t("admin.budget_investments.edit.mark_as_incompatible") %>
- <% end %>
+ <%= f.check_box :incompatible,
+ title: t("admin.budget_investments.edit.compatibility"),
+ label: t("admin.budget_investments.edit.mark_as_incompatible") %>
<% end %>
<%= t("admin.budget_investments.edit.selection") %>
- <%= f.label :selected do %>
- <%= f.check_box :selected, title: t("admin.budget_investments.edit.selection"), label: false %>
- <%= t("admin.budget_investments.edit.mark_as_selected") %>
- <% end %>
+ <%= f.check_box :selected,
+ title: t("admin.budget_investments.edit.selection"),
+ label: t("admin.budget_investments.edit.mark_as_selected") %>
diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb
index 4fb08a56b..d81a92b06 100644
--- a/app/views/budgets/investments/_form.html.erb
+++ b/app/views/budgets/investments/_form.html.erb
@@ -89,14 +89,11 @@
<% unless current_user.manager? %>
- <%= f.label :terms_of_service do %>
- <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
-
- <%= t("form.accept_terms",
- policy: link_to(t("form.policy"), "/privacy", target: "blank"),
- conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
-
- <% end %>
+ <%= f.check_box :terms_of_service,
+ title: t("form.accept_terms_title"),
+ label: t("form.accept_terms",
+ policy: link_to(t("form.policy"), "/privacy", target: "blank"),
+ conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
<% end %>
diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb
index 9e828bd08..40613b044 100644
--- a/app/views/comments/_form.html.erb
+++ b/app/views/comments/_form.html.erb
@@ -18,14 +18,18 @@
<% if can? :comment_as_moderator, commentable %>
- <%= f.check_box :as_moderator, title: t("comments.form.comment_as_moderator"), id: "comment-as-moderator-#{css_id}", label: false %>
- <%= label_tag "comment-as-moderator-#{css_id}", t("comments.form.comment_as_moderator"), class: "checkbox" %>
+ <%= 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}" } %>
<% end %>
<% if can? :comment_as_administrator, commentable %>
- <%= f.check_box :as_administrator, title: t("comments.form.comment_as_admin"), id: "comment-as-administrator-#{css_id}", label: false %>
- <%= label_tag "comment-as-administrator-#{css_id}", t("comments.form.comment_as_admin"), class: "checkbox" %>
+ <%= 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}" } %>
<% end %>
diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb
index 7075e1cf0..69639fbb4 100644
--- a/app/views/debates/_form.html.erb
+++ b/app/views/debates/_form.html.erb
@@ -35,14 +35,12 @@
<% if @debate.new_record? %>
- <%= f.label :terms_of_service do %>
- <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
-
- <%= t("form.accept_terms",
- policy: link_to(t("form.policy"), "/privacy", target: "blank"),
- conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
-
- <% end %>
+ <%= f.check_box :terms_of_service,
+ title: t("form.accept_terms_title"),
+ label: t("form.accept_terms",
+ policy: link_to(t("form.policy"), "/privacy", target: "blank"),
+ conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
+ ).html_safe %>
<% end %>
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb
index f6e62791d..cba9e6ec0 100644
--- a/app/views/devise/sessions/new.html.erb
+++ b/app/views/devise/sessions/new.html.erb
@@ -21,10 +21,7 @@
<% if devise_mapping.rememberable? -%>
- <%= f.label :remember_me do %>
- <%= f.check_box :remember_me, title: t("devise_views.sessions.new.remember_me"), label: false %>
- <%= t("devise_views.sessions.new.remember_me") %>
- <% end %>
+ <%= f.check_box :remember_me, label: t("devise_views.sessions.new.remember_me") %>
<% end -%>
diff --git a/app/views/legislation/proposals/_form.html.erb b/app/views/legislation/proposals/_form.html.erb
index 8fd543039..b6d702c27 100644
--- a/app/views/legislation/proposals/_form.html.erb
+++ b/app/views/legislation/proposals/_form.html.erb
@@ -69,14 +69,12 @@
<% if @proposal.new_record? %>
- <%= f.label :terms_of_service do %>
- <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
-
- <%= t("form.accept_terms",
- policy: link_to(t("form.policy"), "/privacy", target: "blank"),
- conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
-
- <% end %>
+ <%= f.check_box :terms_of_service,
+ title: t("form.accept_terms_title"),
+ label: t("form.accept_terms",
+ policy: link_to(t("form.policy"), "/privacy", target: "blank"),
+ conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
+ ).html_safe %>
<% end %>
diff --git a/app/views/map_locations/_form_fields.html.erb b/app/views/map_locations/_form_fields.html.erb
index f2292a42e..132c39a00 100644
--- a/app/views/map_locations/_form_fields.html.erb
+++ b/app/views/map_locations/_form_fields.html.erb
@@ -18,14 +18,8 @@
id: map_location_input_id(parent_class, "zoom") %>
- <%= form.label :skip_map do %>
- <%= form.check_box :skip_map,
- title: t("#{i18n_namespace}.form.map_skip_checkbox"),
- label: false,
- class: "js-toggle-map" %>
-
- <%= t("#{i18n_namespace}.form.map_skip_checkbox") %>
-
- <% end %>
+ <%= form.check_box :skip_map,
+ label: t("#{i18n_namespace}.form.map_skip_checkbox"),
+ class: "js-toggle-map" %>
<% end %>
diff --git a/app/views/organizations/registrations/new.html.erb b/app/views/organizations/registrations/new.html.erb
index db354259e..705f27fde 100644
--- a/app/views/organizations/registrations/new.html.erb
+++ b/app/views/organizations/registrations/new.html.erb
@@ -27,12 +27,14 @@
label: t("devise_views.organizations.registrations.new.password_confirmation_label"),
placeholder: t("devise_views.organizations.registrations.new.password_confirmation_label") %>
- <%= f.label :terms_of_service do %>
- <%= f.check_box :terms_of_service, title: t("devise_views.users.registrations.new.terms_title"), label: false %>
-
- <%= t("devise_views.users.registrations.new.terms",
- terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions", title: t("shared.target_blank_html"), target: "_blank")).html_safe %>
- <% end %>
+ <%= f.check_box :terms_of_service,
+ title: t("devise_views.users.registrations.new.terms_title"),
+ label: t("devise_views.users.registrations.new.terms",
+ terms: link_to(t("devise_views.users.registrations.new.terms_link"),
+ "/conditions",
+ title: t("shared.target_blank_html"),
+ target: "_blank")
+ ).html_safe %>
<%= f.submit t("devise_views.organizations.registrations.new.submit"), class: "button expanded" %>
diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb
index d87385e20..7e20272f9 100644
--- a/app/views/proposals/_form.html.erb
+++ b/app/views/proposals/_form.html.erb
@@ -101,14 +101,12 @@
<% if @proposal.new_record? %>
- <%= f.label :terms_of_service do %>
- <%= f.check_box :terms_of_service, title: t("form.accept_terms_title"), label: false %>
-
- <%= t("form.accept_terms",
- policy: link_to(t("form.policy"), "/privacy", target: "blank"),
- conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
-
- <% end %>
+ <%= f.check_box :terms_of_service,
+ title: t("form.accept_terms_title"),
+ label: t("form.accept_terms",
+ policy: link_to(t("form.policy"), "/privacy", target: "blank"),
+ conditions: link_to(t("form.conditions"), "/conditions", target: "blank")
+ ).html_safe %>
<% end %>
diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb
index 7309606a4..c97b1befb 100644
--- a/app/views/users/registrations/new.html.erb
+++ b/app/views/users/registrations/new.html.erb
@@ -36,15 +36,14 @@
<%= f.text_field :redeemable_code, placeholder: t("devise_views.users.registrations.new.redeemable_code") %>
<% end %>
- <%= f.label :terms_of_service do %>
- <%= f.check_box :terms_of_service, title: t("devise_views.users.registrations.new.terms_title"), label: false %>
-
- <%= t("devise_views.users.registrations.new.terms",
- terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions",
- title: t("shared.target_blank_html"),
- target: "_blank")).html_safe %>
-
- <% end %>
+ <%= f.check_box :terms_of_service,
+ title: t("devise_views.users.registrations.new.terms_title"),
+ label: t("devise_views.users.registrations.new.terms",
+ terms: link_to(t("devise_views.users.registrations.new.terms_link"), "/conditions",
+ title: t("shared.target_blank_html"),
+ target: "_blank")
+ ).html_safe %>
+
<%= f.submit t("devise_views.users.registrations.new.submit"), class: "button expanded" %>
diff --git a/app/views/valuation/budget_investments/_dossier_form.html.erb b/app/views/valuation/budget_investments/_dossier_form.html.erb
index 60ec0e2d5..5f601b18b 100644
--- a/app/views/valuation/budget_investments/_dossier_form.html.erb
+++ b/app/views/valuation/budget_investments/_dossier_form.html.erb
@@ -75,14 +75,12 @@
- <%= f.label :valuation_finished do %>
- <%= f.check_box :valuation_finished,
- title: t("valuation.budget_investments.edit.valuation_finished"),
- label: false, 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") %>
- <%= t("valuation.budget_investments.edit.valuation_finished") %>
- <% end %>
+ <%= 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/app/views/verification/residence/new.html.erb b/app/views/verification/residence/new.html.erb
index c18d42ccc..9c9adb322 100644
--- a/app/views/verification/residence/new.html.erb
+++ b/app/views/verification/residence/new.html.erb
@@ -77,16 +77,13 @@
- <%= f.label :terms_of_service do %>
- <%= f.check_box :terms_of_service, title: t("verification.residence.new.accept_terms_text_title"), label: false %>
-
- <%= t("verification.residence.new.accept_terms_text",
- terms_url: link_to(t("verification.residence.new.terms"), "/census_terms",
- title: t("shared.target_blank_html"),
- target: "_blank")).html_safe
- %>
-
- <% end %>
+ <%= f.check_box :terms_of_service,
+ title: t("verification.residence.new.accept_terms_text_title"),
+ label: t("verification.residence.new.accept_terms_text",
+ terms_url: link_to(t("verification.residence.new.terms"), "/census_terms",
+ title: t("shared.target_blank_html"),
+ target: "_blank")
+ ).html_safe %>
diff --git a/lib/consul_form_builder.rb b/lib/consul_form_builder.rb
index fd7a24c98..205339422 100644
--- a/lib/consul_form_builder.rb
+++ b/lib/consul_form_builder.rb
@@ -17,6 +17,16 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
end
end
+ def check_box(attribute, options = {})
+ if options[:label] != false
+ label = content_tag(:span, label_text(object, attribute, options[:label]), class: "checkbox")
+
+ super(attribute, options.merge(label: label))
+ else
+ super
+ end
+ end
+
private
def label_with_hint(attribute, options)
@@ -24,6 +34,14 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
help_text(attribute, options)
end
+ def label_text(object, attribute, text)
+ if text.nil? || text == true
+ default_label_text(object, attribute)
+ else
+ text
+ end
+ end
+
def help_text(attribute, options)
if options[:hint]
content_tag :span, options[:hint], class: "help-text", id: help_text_id(attribute, options)