Browse Source

CLDC-1180 Link to radio/checkbox errors from summary (#2835)

* try linking errors

* Change question ids to symbols and update checkboxes
pull/2844/head
kosiakkatrina 3 weeks ago committed by GitHub
parent
commit
5aff4d9989
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      app/views/form/_checkbox_question.html.erb
  2. 8
      app/views/form/_radio_question.html.erb

5
app/views/form/_checkbox_question.html.erb

@ -6,16 +6,17 @@
hint: { text: question.hint_text&.html_safe } do %> hint: { text: question.hint_text&.html_safe } do %>
<% after_divider = false %> <% 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") %> <% if key.starts_with?("divider") %>
<% after_divider = true %> <% after_divider = true %>
<%= f.govuk_check_box_divider %> <%= f.govuk_check_box_divider %>
<% else %> <% else %>
<%= f.govuk_check_box question.id, key, <%= f.govuk_check_box question.id.to_sym, key,
label: { text: option["value"] }, label: { text: option["value"] },
hint: { text: option["hint"] }, hint: { text: option["hint"] },
checked: @log[key] == 1, checked: @log[key] == 1,
exclusive: after_divider, exclusive: after_divider,
link_errors: index.zero? ? true : nil,
**stimulus_html_attributes(question) %> **stimulus_html_attributes(question) %>
<% end %> <% end %>
<% end %> <% end %>

8
app/views/form/_radio_question.html.erb

@ -18,22 +18,24 @@
legend: legend(question, page_header, conditional), legend: legend(question, page_header, conditional),
hint: { text: question.hint_text&.html_safe } do %> 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") %> <% if key.starts_with?("divider") %>
<%= f.govuk_radio_divider %> <%= f.govuk_radio_divider %>
<% else %> <% else %>
<% conditional_question = find_conditional_question(@page, question, key) %> <% conditional_question = find_conditional_question(@page, question, key) %>
<% if conditional_question.nil? %> <% if conditional_question.nil? %>
<%= f.govuk_radio_button question.id, <%= f.govuk_radio_button question.id.to_sym,
key, key,
label: { text: options["value"] }, label: { text: options["value"] },
hint: { text: options["hint"] }, hint: { text: options["hint"] },
link_errors: index.zero? ? true : nil,
**stimulus_html_attributes(question) %> **stimulus_html_attributes(question) %>
<% else %> <% else %>
<%= f.govuk_radio_button question.id, <%= f.govuk_radio_button question.id.to_sym,
key, key,
label: { text: options["value"] }, label: { text: options["value"] },
hint: { text: options["hint"] }, hint: { text: options["hint"] },
link_errors: index.zero? ? true : nil,
**stimulus_html_attributes(question) do %> **stimulus_html_attributes(question) do %>
<%= render partial: "#{conditional_question.type}_question", locals: { <%= render partial: "#{conditional_question.type}_question", locals: {
question: conditional_question, question: conditional_question,

Loading…
Cancel
Save