From 50b102e8f9d4b0a6fe20373e590f09295ef7f06f Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Sat, 25 Sep 2021 16:36:39 +0100 Subject: [PATCH] Enable dividers in radio button and checkbox answer options --- app/views/form/_checkbox_question.html.erb | 14 ++++++++++++-- app/views/form/_radio_question.html.erb | 14 ++++++++++++-- config/forms/2021_2022.json | 4 ++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/views/form/_checkbox_question.html.erb b/app/views/form/_checkbox_question.html.erb index b72df6ba9..1c379f3e3 100644 --- a/app/views/form/_checkbox_question.html.erb +++ b/app/views/form/_checkbox_question.html.erb @@ -1,5 +1,15 @@ -<% answer_options = question["answer_options"].map { |k, v| OpenStruct.new(id: k.to_i, value: v) } %> +<%= f.govuk_check_boxes_fieldset question_key, + legend: { text: question["header"], size: "l" }, + hint: { text: question["hint_text"] } do %> + + <% question["answer_options"].map do |key, val| %> + <% if key == "divider" %> + <%= f.govuk_check_box_divider %> + <% else %> + <%= f.govuk_check_box question_key, key, label: { text: val } %> + <% end %> + <% end %> +<% end %> -<%= f.govuk_collection_check_boxes question_key, answer_options, :id, :value, legend: { text: question["header"], size: "l" }, hint: { text: question["hint_text"] } %> <%= f.hidden_field :previous_page, value: page_key %> <%= f.hidden_field :case_log_id, value: case_log_id %> diff --git a/app/views/form/_radio_question.html.erb b/app/views/form/_radio_question.html.erb index de6f687b9..c6cd8cae0 100644 --- a/app/views/form/_radio_question.html.erb +++ b/app/views/form/_radio_question.html.erb @@ -1,5 +1,15 @@ -<% answer_options = question["answer_options"].map { |k, v| OpenStruct.new(id: k.to_i, value: v) } %> +<%= f.govuk_radio_buttons_fieldset question_key, + legend: { text: question["header"], size: "l" }, + hint: { text: question["hint_text"] } do %> + + <% question["answer_options"].map do |key, val| %> + <% if key == "divider" %> + <%= f.govuk_radio_divider %> + <% else %> + <%= f.govuk_radio_button question_key, key, label: { text: val } %> + <% end %> + <% end %> +<% end %> -<%= f.govuk_collection_radio_buttons question_key, answer_options, :id, :value, legend: { text: question["header"], size: "l" }, hint: { text: question["hint_text"] } %> <%= f.hidden_field :previous_page, value: page_key %> <%= f.hidden_field :case_log_id, value: case_log_id %> diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index c6f157be7..8beedd445 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -368,7 +368,9 @@ "2": "Level access housing", "3": "Other disability requirements", "4": "No disability requirements", + "divider": true, "5": "Do not know", + "divider": true, "6": "Prefer not to say" } } @@ -393,6 +395,7 @@ "7": "Mental health - such as depression, anxiety, schizophrenia or bipolar", "8": "Socially or behaviourally - such as those associated with autism spectral disorder (ASD) including Aspergers’ or attention deficit hyperactivity disorder (ADHD))", "9": "Other", + "divider": true, "10": "Prefer not to say" } } @@ -1550,6 +1553,7 @@ "1": "Living in insanitary or overcrowded or unsatisfactory housing", "2": "A need to move on medical and welfare grounds (including a disability)", "3": "A need to move to avoid hardship to themselves or others", + "divider": true, "4": "Do not know" } }