diff --git a/app/controllers/jobseekers/job_applications/build_controller.rb b/app/controllers/jobseekers/job_applications/build_controller.rb index 79d27239a0..e64afaa9ce 100644 --- a/app/controllers/jobseekers/job_applications/build_controller.rb +++ b/app/controllers/jobseekers/job_applications/build_controller.rb @@ -55,15 +55,15 @@ def form_attributes when "show" form_class.load_form(job_application) when "update" - form_params + form_class.load_form(job_application).merge(form_params) end case step when :professional_status attributes.merge(jobseeker_profile_attributes) .merge(trn_params) - when :references - attributes.merge(references: job_application.references) + # when :references + # attributes.merge(references: job_application.references) when :employment_history attributes.merge(unexplained_employment_gaps: job_application.unexplained_employment_gaps) else @@ -128,8 +128,6 @@ def jobseeker_profile_attributes end def trn_params - return {} unless step == :professional_status - { teacher_reference_number: form_params[:teacher_reference_number] || current_jobseeker&.jobseeker_profile&.teacher_reference_number, has_teacher_reference_number: form_params[:has_teacher_reference_number] || current_jobseeker&.jobseeker_profile&.has_teacher_reference_number, diff --git a/app/form_models/jobseekers/job_application/ask_for_support_form.rb b/app/form_models/jobseekers/job_application/ask_for_support_form.rb index 541b8bd868..1e50123523 100644 --- a/app/form_models/jobseekers/job_application/ask_for_support_form.rb +++ b/app/form_models/jobseekers/job_application/ask_for_support_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :ask_for_support))) + super.merge(completed_attrs(model, :ask_for_support)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/base_form.rb b/app/form_models/jobseekers/job_application/base_form.rb index c5b26c818a..8cd8e7c132 100644 --- a/app/form_models/jobseekers/job_application/base_form.rb +++ b/app/form_models/jobseekers/job_application/base_form.rb @@ -15,11 +15,7 @@ def storable_fields end def load_form(model) - load_form_attributes(model.attributes) - end - - def load_form_attributes(attrs) - attrs.symbolize_keys.slice(*fields) + model.slice(*storable_fields) end end end diff --git a/app/form_models/jobseekers/job_application/catholic_form.rb b/app/form_models/jobseekers/job_application/catholic_form.rb index 199eb7c417..279bc80bff 100644 --- a/app/form_models/jobseekers/job_application/catholic_form.rb +++ b/app/form_models/jobseekers/job_application/catholic_form.rb @@ -14,10 +14,7 @@ def unstorable_fields end def load_form(model) - # baptism_certificate is an upload so is not an attribute - load_form_attributes(model.attributes - .merge(completed_attrs(model, :catholic)) - .merge(baptism_certificate: model.baptism_certificate)) + model.slice(*storable_fields).merge(completed_attrs(model, :catholic)) end end diff --git a/app/form_models/jobseekers/job_application/declarations_form.rb b/app/form_models/jobseekers/job_application/declarations_form.rb index 69659f55eb..6da58ff449 100644 --- a/app/form_models/jobseekers/job_application/declarations_form.rb +++ b/app/form_models/jobseekers/job_application/declarations_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :declarations))) + super.merge(completed_attrs(model, :declarations)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/employment_history_form.rb b/app/form_models/jobseekers/job_application/employment_history_form.rb index 2ed93ebc28..b7da003649 100644 --- a/app/form_models/jobseekers/job_application/employment_history_form.rb +++ b/app/form_models/jobseekers/job_application/employment_history_form.rb @@ -18,7 +18,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :employment_history))) + super.merge(completed_attrs(model, :employment_history)) end end attr_accessor(*FIELDS, :unexplained_employment_gaps) diff --git a/app/form_models/jobseekers/job_application/equal_opportunities_form.rb b/app/form_models/jobseekers/job_application/equal_opportunities_form.rb index 7cb0f0b499..114abd5e97 100644 --- a/app/form_models/jobseekers/job_application/equal_opportunities_form.rb +++ b/app/form_models/jobseekers/job_application/equal_opportunities_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :equal_opportunities))) + super.merge(completed_attrs(model, :equal_opportunities)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/non_catholic_form.rb b/app/form_models/jobseekers/job_application/non_catholic_form.rb index 9a331ef29e..197772b482 100644 --- a/app/form_models/jobseekers/job_application/non_catholic_form.rb +++ b/app/form_models/jobseekers/job_application/non_catholic_form.rb @@ -11,7 +11,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :non_catholic))) + super.merge(completed_attrs(model, :non_catholic)) end end diff --git a/app/form_models/jobseekers/job_application/personal_details_form.rb b/app/form_models/jobseekers/job_application/personal_details_form.rb index d6b2449bc7..b66a40030b 100644 --- a/app/form_models/jobseekers/job_application/personal_details_form.rb +++ b/app/form_models/jobseekers/job_application/personal_details_form.rb @@ -37,7 +37,7 @@ def load_form(model) new_attrs = { has_ni_number: model.national_insurance_number.present? ? "yes" : "no", }.merge(completed_attrs(model, :personal_details)) - load_form_attributes(model.attributes.merge(new_attrs)) + super.merge(new_attrs) end end diff --git a/app/form_models/jobseekers/job_application/personal_statement_form.rb b/app/form_models/jobseekers/job_application/personal_statement_form.rb index 76c4f2f4d1..b719425af5 100644 --- a/app/form_models/jobseekers/job_application/personal_statement_form.rb +++ b/app/form_models/jobseekers/job_application/personal_statement_form.rb @@ -17,7 +17,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :personal_statement))) + super.merge(completed_attrs(model, :personal_statement)) end end attr_accessor(*FIELDS) diff --git a/app/form_models/jobseekers/job_application/professional_status_form.rb b/app/form_models/jobseekers/job_application/professional_status_form.rb index 1b2ecdd5a6..9ef30e8e9e 100644 --- a/app/form_models/jobseekers/job_application/professional_status_form.rb +++ b/app/form_models/jobseekers/job_application/professional_status_form.rb @@ -11,11 +11,11 @@ class ProfessionalStatusForm < BaseForm qualified_teacher_status_details statutory_induction_complete teacher_reference_number - has_teacher_reference_number statutory_induction_complete_details ].freeze attr_accessor(*FIELDS) + attr_accessor(:has_teacher_reference_number) class << self def storable_fields @@ -27,7 +27,8 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :professional_status))) + super.merge(completed_attrs(model, :professional_status)) + .merge(has_teacher_reference_number: model[:teacher_reference_number].present? ? "yes" : "no") end end @@ -65,9 +66,5 @@ def initialize(attributes = {}) completed_attribute(:professional_status) end - - def load(attrs) - super(attrs.merge(has_teacher_reference_number: attrs[:teacher_reference_number].present? ? "yes" : "no")) - end end end diff --git a/app/form_models/jobseekers/job_application/qualifications_form.rb b/app/form_models/jobseekers/job_application/qualifications_form.rb index 7527ce2a1e..bb1c5412ae 100644 --- a/app/form_models/jobseekers/job_application/qualifications_form.rb +++ b/app/form_models/jobseekers/job_application/qualifications_form.rb @@ -11,7 +11,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :qualifications))) + super.merge(completed_attrs(model, :qualifications)) end end diff --git a/app/form_models/jobseekers/job_application/references_form.rb b/app/form_models/jobseekers/job_application/references_form.rb index ea5bd24df1..5d80c729fa 100644 --- a/app/form_models/jobseekers/job_application/references_form.rb +++ b/app/form_models/jobseekers/job_application/references_form.rb @@ -15,9 +15,8 @@ def optional? end def load_form(model) - load_form_attributes(model.attributes - .merge(references: model.references) - .merge(completed_attrs(model, :references))) + super.merge(references: model.references) + .merge(completed_attrs(model, :references)) end end diff --git a/app/form_models/jobseekers/job_application/training_and_cpds_form.rb b/app/form_models/jobseekers/job_application/training_and_cpds_form.rb index e7a45900fd..41584f6392 100644 --- a/app/form_models/jobseekers/job_application/training_and_cpds_form.rb +++ b/app/form_models/jobseekers/job_application/training_and_cpds_form.rb @@ -11,7 +11,7 @@ def unstorable_fields end def load_form(model) - load_form_attributes(model.attributes.merge(completed_attrs(model, :training_and_cpds))) + super.merge(completed_attrs(model, :training_and_cpds)) end end diff --git a/app/views/jobseekers/job_applications/apply.html.slim b/app/views/jobseekers/job_applications/apply.html.slim index 0af78d5f79..fc486fc3ce 100644 --- a/app/views/jobseekers/job_applications/apply.html.slim +++ b/app/views/jobseekers/job_applications/apply.html.slim @@ -1,6 +1,6 @@ - content_for :page_title_prefix, job_application_page_title_prefix(review_form, t(".title")) -= job_application_review(@job_application) do |r| += job_application_review(@job_applicationm, show_sidebar: false) do |r| - r.with_header do = render "banner" diff --git a/app/views/jobseekers/job_applications/build/catholic.html.slim b/app/views/jobseekers/job_applications/build/catholic.html.slim index faf5e79bb2..00c11a0651 100644 --- a/app/views/jobseekers/job_applications/build/catholic.html.slim +++ b/app/views/jobseekers/job_applications/build/catholic.html.slim @@ -14,7 +14,7 @@ p.govuk-body = t(".non_catholics_apply") - = form_for form, url: jobseekers_job_application_build_path(job_application, :catholic), method: :patch do |f| + = form_for form, url: jobseekers_job_application_build_path(job_application, :catholic), method: :patch, multipart: true do |f| = f.govuk_error_summary = f.govuk_radio_buttons_fieldset :following_religion do @@ -33,8 +33,7 @@ = f.govuk_radio_button :religious_reference_type, :baptism_certificate do = f.govuk_file_field :baptism_certificate, label: { size: "s" }, - accept: BaseForm::VALID_DOCUMENT_TYPES.map(&:downcase).join(","), - enctype: "multipart/form-data" + accept: BaseForm::VALID_DOCUMENT_TYPES.map(&:downcase).join(",") = f.govuk_radio_button :religious_reference_type, :baptism_date do = f.govuk_text_area :baptism_address, rows: 6 = f.govuk_date_field :baptism_date