<%= decidim_form_for(@form, url: answer_survey_path(survey), method: :post, html: { class: "form answer-survey" }) do |form| %>
<% @form.answers.each_with_index do |answer, answer_idx| %>
<% field_id = "survey_#{survey.id}_question_#{answer.question.id}_answer_body" %>
<%= label_tag field_id , "#{answer_idx + 1}. #{translated_attribute(answer.question.body)} #{'*' if answer.question.mandatory?}" %>
<% case answer.question.question_type %>
<% when "short_answer" %>
<%= text_field_tag "survey[answers][#{answer_idx}][body][]", answer.body.try(:first), id: field_id, class: "#{'is-invalid-input' unless answer.errors.empty?}" %>
<% when "long_answer" %>
<%= text_area_tag "survey[answers][#{answer_idx}][body][]", answer.body.try(:first), id: field_id, class: "#{'is-invalid-input' unless answer.errors.empty?}", rows: 10 %>
<% when "single_option" %>
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
<%= label_tag "#{field_id}_option_#{idx}" do %>
<%= radio_button_tag "survey[answers][#{answer_idx}][body][]", translated_attribute(answer_option["body"]), answer.body.try(:include?, translated_attribute(answer_option["body"])), id: "#{field_id}_option_#{idx}" %>
<%= translated_attribute(answer_option["body"]) %>
<% end %>
<% end %>
<% when "multiple_option" %>
<% answer.question.answer_options.each_with_index do |answer_option, idx| %>
<%= label_tag "#{field_id}_option_#{idx}" do %>
<%= check_box_tag "survey[answers][#{answer_idx}][body][]", translated_attribute(answer_option["body"]), answer.body.try(:include?, translated_attribute(answer_option["body"])), id: "#{field_id}_option_#{idx}" %>
<%= translated_attribute(answer_option["body"]) %>
<% end %>
<% end %>
<% end %>
<%= hidden_field_tag "survey[answers][#{answer_idx}][question_id]", answer.question.id %>
<% answer.errors.full_messages.each do |msg| %>
<%= content_tag :small, msg, class: "form-error is-visible" %>
<% end %>
<%= form.check_box :tos_agreement, label: t(".tos_agreement"), id: "survey_tos_agreement" %>
<%= decidim_sanitize translated_attribute survey.tos %>
<%= form.submit t(".submit"), class: "button", data: { confirm: t('.are_you_sure') } %>