diff --git a/app/controllers/assessor_interface/notes_controller.rb b/app/controllers/assessor_interface/notes_controller.rb index a5bda9486f..84aeff1171 100644 --- a/app/controllers/assessor_interface/notes_controller.rb +++ b/app/controllers/assessor_interface/notes_controller.rb @@ -17,7 +17,7 @@ def create ) if @form.save - redirect_to params[:next].presence || + redirect_to history_stack.pop_back || [:assessor_interface, application_form] else render :new, status: :unprocessable_entity diff --git a/app/views/assessor_interface/notes/new.html.erb b/app/views/assessor_interface/notes/new.html.erb index aa177b2713..156d67fed9 100644 --- a/app/views/assessor_interface/notes/new.html.erb +++ b/app/views/assessor_interface/notes/new.html.erb @@ -1,9 +1,7 @@ <% content_for :page_title, title_with_error_prefix("Add a note", error: @form.errors.any?) %> -<% content_for :back_link_url, params[:next].presence || assessor_interface_application_form_path(@application_form) %> +<% content_for :back_link_url, back_history_path(default: assessor_interface_application_form_path(@application_form)) %> <%= form_with model: @form, url: [:assessor_interface, @application_form, :notes] do |f| %> - <%= hidden_field_tag :next, params[:next] %> - <%= f.govuk_error_summary %> <%= f.govuk_text_area :text, label: { tag: "h1", size: "l" }, rows: 5 %> diff --git a/app/views/shared/_assessor_header.html.erb b/app/views/shared/_assessor_header.html.erb index de08d55892..8cb0e0fd37 100644 --- a/app/views/shared/_assessor_header.html.erb +++ b/app/views/shared/_assessor_header.html.erb @@ -2,6 +2,6 @@

<%= title %>

<%= govuk_button_link_to "Add note".html_safe, - new_assessor_interface_application_form_note_path(application_form, next: request.path), + [:new, :assessor_interface, @application_form, :note], secondary: true %>