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.
This commit is contained in:
Javi Martín
2019-06-23 15:41:54 +02:00
parent 612e5ad832
commit 06be5e132f
3 changed files with 6 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
<%= form_tag(create_answer_question_path(question, token: token), method: :post, remote: true) do %> <%= form_tag(create_answer_question_path(question, token: token), method: :post, remote: true) do %>
<label> You can add your own answer</label> <% id = "your_answer_#{SecureRandom.hex}" %>
<input type="text" class="medium-10" name="answer"> <%= label_tag :answer, t("poll_questions.show.your_answer"), for: id %>
<input class="button success" type="submit" value="<%= t("poll_questions.show.add_answer") %>"> <%= text_field_tag :answer, nil, class: "medium-10", id: id %>
<%= submit_tag t("poll_questions.show.add_answer"), class: "button success" %>
<% end %> <% end %>

View File

@@ -701,6 +701,7 @@ en:
show: show:
vote_answer: "Vote %{answer}" vote_answer: "Vote %{answer}"
voted: "You have voted %{answer}" voted: "You have voted %{answer}"
your_answer: "You can add your own answer"
add_answer: "Add answer" add_answer: "Add answer"
description: description:
multiple: "You can select a maximum of %{maximum} answers." multiple: "You can select a maximum of %{maximum} answers."

View File

@@ -699,6 +699,7 @@ es:
show: show:
vote_answer: "Votar %{answer}" vote_answer: "Votar %{answer}"
voted: "Has votado %{answer}" voted: "Has votado %{answer}"
your_answer: "Puedes añadir tu propia respuesta"
add_answer: "Añadir respuesta" add_answer: "Añadir respuesta"
description: description:
multiple: "Puedes seleccionar un máximo de %{maximum} respuestas." multiple: "Puedes seleccionar un máximo de %{maximum} respuestas."