Skip to content

Commit 22ccdf2

Browse files
committed
Refactor new and edit parent relationship views to use shared _fields partial
1 parent 7152944 commit 22ccdf2

3 files changed

Lines changed: 41 additions & 77 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<%= f.fields_for :parent do |parent_f| %>
2+
<%= parent_f.govuk_text_field :full_name, label: { text: "Name" } %>
3+
<% end %>
4+
5+
<%= f.govuk_radio_buttons_fieldset :type, legend: { text: "Relationship to child", size: "s" } do %>
6+
<%= f.govuk_radio_button :type, :mother, label: { text: "Mum" }, link_errors: true %>
7+
<%= f.govuk_radio_button :type, :father, label: { text: "Dad" } %>
8+
<%= f.govuk_radio_button :type, :guardian, label: { text: "Guardian" } %>
9+
<%= f.govuk_radio_button :type, :other, label: { text: "Other" } do %>
10+
<%= f.govuk_text_field :other_name, label: { text: "Relationship to the child" }, hint: { text: "For example, carer" } %>
11+
<% end %>
12+
<% end %>
13+
14+
<%= f.fields_for :parent do |parent_f| %>
15+
<%= parent_f.govuk_text_field :email, label: { text: "Email address" } %>
16+
<%= parent_f.govuk_text_field :phone, label: { text: "Phone number" } %>
17+
18+
<%= parent_f.govuk_check_boxes_fieldset :phone_receive_updates, multiple: false, legend: nil do %>
19+
<%= parent_f.govuk_check_box :phone_receive_updates, 1, 0, multiple: false, link_errors: true, label: { text: "Get updates by text message" } %>
20+
<% end %>
21+
22+
<%= parent_f.govuk_radio_buttons_fieldset :contact_method_type,
23+
legend: { text: "Does the parent have any specific needs?", size: "s" } do %>
24+
<%= parent_f.govuk_radio_button :contact_method_type, "text",
25+
label: { text: "They can only receive text messages" },
26+
link_errors: true %>
27+
<%= parent_f.govuk_radio_button :contact_method_type, "voice",
28+
label: { text: "They can only receive voice calls" } %>
29+
<%= parent_f.govuk_radio_button :contact_method_type, "other",
30+
label: { text: "Other" } do %>
31+
<%= parent_f.govuk_text_area :contact_method_other_details,
32+
label: { text: "Give details" } %>
33+
<% end %>
34+
<%= parent_f.govuk_radio_divider %>
35+
<%= parent_f.govuk_radio_button :contact_method_type, "any",
36+
label: { text: "They do not have specific needs" } %>
37+
<% end %>
38+
<% end %>

app/views/parent_relationships/edit.html.erb

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,7 @@
1111
<%= page_title %>
1212
<% end %>
1313

14-
<%= f.fields_for :parent do |parent_f| %>
15-
<%= parent_f.govuk_text_field :full_name, label: { text: "Name" } %>
16-
<% end %>
17-
18-
<%= f.govuk_radio_buttons_fieldset :type, legend: { text: "Relationship to child", size: "s" } do %>
19-
<%= f.govuk_radio_button :type, :mother, label: { text: "Mum" }, link_errors: true %>
20-
<%= f.govuk_radio_button :type, :father, label: { text: "Dad" } %>
21-
<%= f.govuk_radio_button :type, :guardian, label: { text: "Guardian" } %>
22-
<%= f.govuk_radio_button :type, :other, label: { text: "Other" } do %>
23-
<%= f.govuk_text_field :other_name, label: { text: "Relationship to the child" }, hint: { text: "For example, carer" } %>
24-
<% end %>
25-
<% end %>
26-
27-
<%= f.fields_for :parent do |parent_f| %>
28-
<%= parent_f.govuk_text_field :email, label: { text: "Email address" } %>
29-
<%= parent_f.govuk_text_field :phone, label: { text: "Phone number" } %>
30-
31-
<%= parent_f.govuk_check_boxes_fieldset :phone_receive_updates, multiple: false, legend: nil do %>
32-
<%= parent_f.govuk_check_box :phone_receive_updates, 1, 0, multiple: false, link_errors: true, label: { text: "Get updates by text message" } %>
33-
<% end %>
34-
35-
<%= parent_f.govuk_radio_buttons_fieldset :contact_method_type,
36-
legend: { text: "Does the parent have any specific needs?", size: "s" } do %>
37-
<%= parent_f.govuk_radio_button :contact_method_type, "text",
38-
label: { text: "They can only receive text messages" },
39-
link_errors: true %>
40-
<%= parent_f.govuk_radio_button :contact_method_type, "voice",
41-
label: { text: "They can only receive voice calls" } %>
42-
<%= parent_f.govuk_radio_button :contact_method_type, "other",
43-
label: { text: "Other" } do %>
44-
<%= parent_f.govuk_text_area :contact_method_other_details,
45-
label: { text: "Give details" } %>
46-
<% end %>
47-
<%= parent_f.govuk_radio_divider %>
48-
<%= parent_f.govuk_radio_button :contact_method_type, "any",
49-
label: { text: "They do not have specific needs" } %>
50-
<% end %>
51-
<% end %>
14+
<%= render "fields", f: %>
5215

5316
<%= f.govuk_submit "Continue" %>
5417
<% end %>

app/views/parent_relationships/new.html.erb

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,44 +14,7 @@
1414
<%= page_title %>
1515
<% end %>
1616

17-
<%= f.fields_for :parent do |parent_f| %>
18-
<%= parent_f.govuk_text_field :full_name, label: { text: "Name" } %>
19-
<% end %>
20-
21-
<%= f.govuk_radio_buttons_fieldset :type, legend: { text: "Relationship to child", size: "s" } do %>
22-
<%= f.govuk_radio_button :type, :mother, label: { text: "Mum" }, link_errors: true %>
23-
<%= f.govuk_radio_button :type, :father, label: { text: "Dad" } %>
24-
<%= f.govuk_radio_button :type, :guardian, label: { text: "Guardian" } %>
25-
<%= f.govuk_radio_button :type, :other, label: { text: "Other" } do %>
26-
<%= f.govuk_text_field :other_name, label: { text: "Relationship to the child" }, hint: { text: "For example, carer" } %>
27-
<% end %>
28-
<% end %>
29-
30-
<%= f.fields_for :parent do |parent_f| %>
31-
<%= parent_f.govuk_text_field :email, label: { text: "Email address" } %>
32-
<%= parent_f.govuk_text_field :phone, label: { text: "Phone number" } %>
33-
34-
<%= parent_f.govuk_check_boxes_fieldset :phone_receive_updates, multiple: false, legend: nil do %>
35-
<%= parent_f.govuk_check_box :phone_receive_updates, 1, 0, multiple: false, link_errors: true, label: { text: "Get updates by text message" } %>
36-
<% end %>
37-
38-
<%= parent_f.govuk_radio_buttons_fieldset :contact_method_type,
39-
legend: { text: "Does the parent have any specific needs?", size: "s" } do %>
40-
<%= parent_f.govuk_radio_button :contact_method_type, "text",
41-
label: { text: "They can only receive text messages" },
42-
link_errors: true %>
43-
<%= parent_f.govuk_radio_button :contact_method_type, "voice",
44-
label: { text: "They can only receive voice calls" } %>
45-
<%= parent_f.govuk_radio_button :contact_method_type, "other",
46-
label: { text: "Other" } do %>
47-
<%= parent_f.govuk_text_area :contact_method_other_details,
48-
label: { text: "Give details" } %>
49-
<% end %>
50-
<%= parent_f.govuk_radio_divider %>
51-
<%= parent_f.govuk_radio_button :contact_method_type, "any",
52-
label: { text: "They do not have specific needs" } %>
53-
<% end %>
54-
<% end %>
17+
<%= render "fields", f: %>
5518

5619
<%= f.govuk_submit "Save" %>
57-
<% end %>
20+
<% end %>

0 commit comments

Comments
 (0)