baarkerlounger
3 years ago
12 changed files with 75 additions and 65 deletions
@ -1,24 +0,0 @@ |
|||||||
class FormController < ApplicationController |
|
||||||
|
|
||||||
FIRST_QUESTION_FOR_SUBSECTION = { |
|
||||||
"Household characteristics" => "case_logs/household/tenant_code", |
|
||||||
} |
|
||||||
|
|
||||||
NEXT_QUESTION = { |
|
||||||
"tenant_code" => "case_logs/household/tenant_age", |
|
||||||
"tenant_age" => "case_logs/household/tenant_gender", |
|
||||||
"tenant_gender" => "case_logs/household/tenant_ethnic_group", |
|
||||||
"tenant_ethnic_group" => "case_logs/household/tenant_nationality" |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
def next_question |
|
||||||
subsection = params[:subsection] |
|
||||||
result = if subsection |
|
||||||
FIRST_QUESTION_FOR_SUBSECTION[subsection] |
|
||||||
else |
|
||||||
NEXT_QUESTION[params[:previous_question]] |
|
||||||
end |
|
||||||
render result |
|
||||||
end |
|
||||||
end |
|
@ -1,11 +1,12 @@ |
|||||||
<%= turbo_frame_tag "case_log_form" do %> |
<%= turbo_frame_tag "case_log_form" do %> |
||||||
<%= form_with action: '/form', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
<%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
||||||
<%= f.govuk_number_field :tenant_age, |
<%= f.govuk_number_field :tenant_age, |
||||||
hint: { text: "More detail" }, |
hint: { text: "More detail" }, |
||||||
label: { text: "What is the tenant's age?", size: "l"}, |
label: { text: "What is the tenant's age?", size: "l"}, |
||||||
min: 0, max: 150, step: 1, width: 20 |
min: 0, max: 150, step: 1, width: 20 |
||||||
%> |
%> |
||||||
<%= f.hidden_field :previous_question, value: :tenant_age %> |
<%= f.hidden_field :previous_question, value: :tenant_age %> |
||||||
|
<%= f.hidden_field :case_log_id, value: case_log_id %> |
||||||
<%= f.govuk_submit "Save and continue" %> |
<%= f.govuk_submit "Save and continue" %> |
||||||
<% end %> |
<% end %> |
||||||
<% end %> |
<% end %> |
||||||
|
@ -1,11 +1,12 @@ |
|||||||
<%= turbo_frame_tag "case_log_form" do %> |
<%= turbo_frame_tag "case_log_form" do %> |
||||||
<%= form_with action: '/form', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
<%= form_with action: '/case_logs', method: "next_question", builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
||||||
<%= f.govuk_text_field :tenant_code, |
<%= f.govuk_text_field :tenant_code, |
||||||
hint: { text: "More detail" }, |
hint: { text: "More detail" }, |
||||||
label: { text: "What is the tenant code?", size: "l"}, |
label: { text: "What is the tenant code?", size: "l"}, |
||||||
width: 20 |
width: 20 |
||||||
%> |
%> |
||||||
<%= f.hidden_field :previous_question, value: :tenant_code %> |
<%= f.hidden_field :previous_question, value: :tenant_code %> |
||||||
|
<%= f.hidden_field :case_log_id, value: case_log_id %> |
||||||
<%= f.govuk_submit "Save and continue" %> |
<%= f.govuk_submit "Save and continue" %> |
||||||
<% end %> |
<% end %> |
||||||
<% end %> |
<% end %> |
||||||
|
@ -1,8 +0,0 @@ |
|||||||
<%= form_with model: @case_log, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %> |
|
||||||
<%= f.govuk_number_field :age, |
|
||||||
hint: { text: "More detail" }, |
|
||||||
label: { text: "What is the tenant's age?", size: "l"}, |
|
||||||
min: 0, max: 150, step: 1, width: 20 |
|
||||||
%> |
|
||||||
<%= f.govuk_submit %> |
|
||||||
<% end %> |
|
Loading…
Reference in new issue