diff --git a/app/views/form/_checkbox_question.html.erb b/app/views/form/_checkbox_question.html.erb index 2e8585e15..b4feb12bd 100644 --- a/app/views/form/_checkbox_question.html.erb +++ b/app/views/form/_checkbox_question.html.erb @@ -6,16 +6,17 @@ hint: { text: question.hint_text&.html_safe } do %> <% after_divider = false %> - <% question.displayed_answer_options(@log).map do |key, option| %> + <% question.displayed_answer_options(@log).each_with_index do |(key, option), index| %> <% if key.starts_with?("divider") %> <% after_divider = true %> <%= f.govuk_check_box_divider %> <% else %> - <%= f.govuk_check_box question.id, key, + <%= f.govuk_check_box question.id.to_sym, key, label: { text: option["value"] }, hint: { text: option["hint"] }, checked: @log[key] == 1, exclusive: after_divider, + link_errors: index.zero? ? true : nil, **stimulus_html_attributes(question) %> <% end %> <% end %> diff --git a/app/views/form/_radio_question.html.erb b/app/views/form/_radio_question.html.erb index 41e98a1cc..bf6abb0d0 100644 --- a/app/views/form/_radio_question.html.erb +++ b/app/views/form/_radio_question.html.erb @@ -18,22 +18,24 @@ legend: legend(question, page_header, conditional), hint: { text: question.hint_text&.html_safe } do %> - <% question.displayed_answer_options(@log, current_user).map do |key, options| %> + <% question.displayed_answer_options(@log, current_user).each_with_index do |(key, options), index| %> <% if key.starts_with?("divider") %> <%= f.govuk_radio_divider %> <% else %> <% conditional_question = find_conditional_question(@page, question, key) %> <% if conditional_question.nil? %> - <%= f.govuk_radio_button question.id, + <%= f.govuk_radio_button question.id.to_sym, key, label: { text: options["value"] }, hint: { text: options["hint"] }, + link_errors: index.zero? ? true : nil, **stimulus_html_attributes(question) %> <% else %> - <%= f.govuk_radio_button question.id, + <%= f.govuk_radio_button question.id.to_sym, key, label: { text: options["value"] }, hint: { text: options["hint"] }, + link_errors: index.zero? ? true : nil, **stimulus_html_attributes(question) do %> <%= render partial: "#{conditional_question.type}_question", locals: { question: conditional_question,