diff --git a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb index cb61f3d9e9..9a7fe74319 100644 --- a/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb +++ b/app/forms/journeys/early_years_payment/practitioner/find_reference_form.rb @@ -11,7 +11,10 @@ class FindReferenceForm < Form def save return false if invalid? - journey_session.answers.assign_attributes(reference_number:) + journey_session.answers.assign_attributes( + reference_number:, + start_email: email, + ) journey_session.save! end diff --git a/app/models/journeys/early_years_payment/practitioner/session_answers.rb b/app/models/journeys/early_years_payment/practitioner/session_answers.rb index 8a9cd43c15..4e96aefd5e 100644 --- a/app/models/journeys/early_years_payment/practitioner/session_answers.rb +++ b/app/models/journeys/early_years_payment/practitioner/session_answers.rb @@ -3,6 +3,7 @@ module EarlyYearsPayment module Practitioner class SessionAnswers < Journeys::SessionAnswers attribute :reference_number, :string + attribute :start_email, :string def policy Policies::EarlyYearsPayments diff --git a/app/views/early_years_payment/practitioner/claims/find_reference.html.erb b/app/views/early_years_payment/practitioner/claims/find_reference.html.erb index 0b1baa624b..af53199a42 100644 --- a/app/views/early_years_payment/practitioner/claims/find_reference.html.erb +++ b/app/views/early_years_payment/practitioner/claims/find_reference.html.erb @@ -5,7 +5,7 @@ <%= form_with model: @form, url: claim_path(current_journey_routing_name, request.query_parameters), method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder, html: { novalidate: false } do |f| %> <%= f.govuk_error_summary %> - <%= f.hidden_field :email, value: params[:email] %> + <%= f.hidden_field :email, value: (params[:email] || journey_session.answers.attributes["start_email"]) %>