From 06be5e132f41bf4ff012943297f4567cd6dbc9b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 23 Jun 2019 15:41:54 +0200 Subject: [PATCH] Fix label in form to add own answer The label text was always in English, and it wasn't associated with any input field. The `SecureRandom` part is a quick hack so we don't get duplicate IDs. Using "your_answer_#{question.id}" might work as well, but right now I'm not sure if the form is sometimes rendered twice for the same question. --- app/views/polls/questions/_new_answer.html.erb | 7 ++++--- config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/views/polls/questions/_new_answer.html.erb b/app/views/polls/questions/_new_answer.html.erb index 2f056bafa..9df88a7e7 100644 --- a/app/views/polls/questions/_new_answer.html.erb +++ b/app/views/polls/questions/_new_answer.html.erb @@ -1,5 +1,6 @@ <%= form_tag(create_answer_question_path(question, token: token), method: :post, remote: true) do %> - - - "> + <% id = "your_answer_#{SecureRandom.hex}" %> + <%= label_tag :answer, t("poll_questions.show.your_answer"), for: id %> + <%= text_field_tag :answer, nil, class: "medium-10", id: id %> + <%= submit_tag t("poll_questions.show.add_answer"), class: "button success" %> <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 2ea40d22e..1b9adb735 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -701,6 +701,7 @@ en: show: vote_answer: "Vote %{answer}" voted: "You have voted %{answer}" + your_answer: "You can add your own answer" add_answer: "Add answer" description: multiple: "You can select a maximum of %{maximum} answers." diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index f879e29aa..f55bb69d8 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -699,6 +699,7 @@ es: show: vote_answer: "Votar %{answer}" voted: "Has votado %{answer}" + your_answer: "Puedes añadir tu propia respuesta" add_answer: "Añadir respuesta" description: multiple: "Puedes seleccionar un máximo de %{maximum} respuestas."