Incorporate label into translatabel field

Suggested by @javierm so that we can take advantage of certain browser
features that rely on a <label> tag being associated with an <input> tag.
This commit is contained in:
Marko Lovic
2018-08-12 18:08:39 +02:00
committed by Javi Martín
parent 3f277c5cdf
commit 61e3b3b406
3 changed files with 12 additions and 7 deletions

View File

@@ -32,7 +32,11 @@ class TranslatableFormBuilder < FoundationRailsHelper::FormBuilder
class: (options.fetch(:class, "") + " js-globalize-attribute"),
style: @template.display_translation?(locale),
data: options.fetch(:data, {}).merge(locale: locale),
label: false
label_options: {
class: (options.fetch(:class, "") + " js-globalize-attribute"),
style: @template.display_translation?(locale),
data: (options.dig(:label_options, :data) || {}) .merge(locale: locale)
}
)
@template.concat send(field_type, "#{method}_#{locale}", final_options)

View File

@@ -29,10 +29,10 @@
<div class="row">
<div class="small-12 medium-6 column">
<%= f.label :title, t("admin.banners.banner.title") %>
<%= f.translatable_text_field :title,
placeholder: t("admin.banners.banner.title"),
data: {js_banner_title: "js_banner_title"}%>
data: {js_banner_title: "js_banner_title"},
label: t("admin.banners.banner.title") %>
</div>
<div class="small-12 medium-6 column">
@@ -45,10 +45,10 @@
<div class="row">
<div class="small-12 column">
<%= f.label :description, t("admin.banners.banner.description") %>
<%= f.translatable_text_field :description,
placeholder: t("admin.banners.banner.description"),
data: {js_banner_description: "js_banner_description"} %>
data: {js_banner_description: "js_banner_description"},
label: t("admin.banners.banner.description") %>
</div>
</div>

View File

@@ -14,8 +14,9 @@
admin_budget_investment_statuses_path %>
</div>
<%= f.label :description, t("admin.milestones.new.description") %>
<%= f.translatable_text_field :description, rows: 5 %>
<%= f.translatable_text_field :description,
rows: 5,
label: t("admin.milestones.new.description") %>
<%= f.label :publication_date, t("admin.milestones.new.date") %>
<%= f.text_field :publication_date,