Add labels to radio buttons automatically

This commit is contained in:
Javi Martín
2019-10-03 20:43:13 +02:00
parent aec84f6522
commit 4f1131d2e5
6 changed files with 15 additions and 12 deletions

View File

@@ -7,22 +7,19 @@
<legend><%= t("valuation.budget_investments.edit.feasibility") %></legend>
<div class="small-4 column">
<span class="radio">
<%= f.radio_button :feasibility, "undecided",
label: t("valuation.budget_investments.edit.undefined_feasible") %>
<%= f.radio_button :feasibility, "undecided" %>
</span>
</div>
<div class="small-4 column">
<span class="radio">
<%= f.radio_button :feasibility, "feasible",
label: t("valuation.budget_investments.edit.feasible") %>
<%= f.radio_button :feasibility, "feasible" %>
</span>
</div>
<div class="small-4 column">
<span class="radio">
<%= f.radio_button :feasibility, "unfeasible",
label: t("valuation.budget_investments.edit.unfeasible") %>
<%= f.radio_button :feasibility, "unfeasible" %>
</span>
</div>
</fieldset>

View File

@@ -153,6 +153,9 @@ en:
organization_name: "If you are proposing in the name of a collective/organization, or on behalf of more people, write its name"
image: "Proposal descriptive image"
image_title: "Image title"
feasibility_feasible: "Feasible"
feasibility_undecided: "Undefined"
feasibility_unfeasible: "Unfeasible"
budget/investment/translation:
title: "Title"
description: "Description"

View File

@@ -60,9 +60,6 @@ en:
price_first_year_html: "Cost during the first year (%{currency}) <small>(optional, data not public)</small>"
price_explanation_html: Price explanation
feasibility: Feasibility
feasible: Feasible
unfeasible: Not feasible
undefined_feasible: Pending
feasible_explanation_html: Feasibility explanation
valuation_finished: Valuation finished
valuation_finished_alert: "Are you sure you want to mark this report as completed? If you do it, it can no longer be modified."

View File

@@ -155,6 +155,9 @@ es:
organization_name: "Si estás proponiendo en nombre de una organización o colectivo, o en nombre de más gente, escribe su nombre"
image: "Imagen descriptiva del proyecto de gasto"
image_title: "Título de la imagen"
feasibility_feasible: "Viable"
feasibility_undecided: "Sin decidir"
feasibility_unfeasible: "Inviable"
budget/investment/translation:
title: "Título"
description: "Descripción"

View File

@@ -60,9 +60,6 @@ es:
price_first_year_html: "Coste en el primer año (%{currency}) <small>(opcional, dato no público)</small>"
price_explanation_html: Informe de coste <small>(opcional, dato público)</small>
feasibility: Viabilidad
feasible: Viable
unfeasible: Inviable
undefined_feasible: Sin decidir
feasible_explanation_html: Informe de inviabilidad <small>(en caso de que lo sea, dato público)</small>
valuation_finished: Informe finalizado
valuation_finished_alert: "¿Estás seguro/a de querer marcar este informe como completado? Una vez hecho, no se puede deshacer la acción."

View File

@@ -27,6 +27,12 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
end
end
def radio_button(attribute, tag_value, options = {})
default_label = object.class.human_attribute_name("#{attribute}_#{tag_value}")
super(attribute, tag_value, { label: default_label }.merge(options))
end
private
def label_with_hint(attribute, options)