diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index d14ec9825..d673389f0 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -25,7 +25,8 @@ class SchemesController < ApplicationController deactivation_date_value = deactivation_date if @scheme.errors.present? - @scheme.deactivation_date_type = params[:scheme][:deactivation_date_type].to_i + @scheme.deactivation_date_type = params[:scheme][:deactivation_date_type] + @scheme.deactivation_date = nil render "toggle_active", locals: { action: "deactivate" }, status: :unprocessable_entity elsif deactivation_date_value.blank? render "toggle_active", locals: { action: "deactivate" } @@ -36,7 +37,7 @@ class SchemesController < ApplicationController end redirect_to scheme_details_path(@scheme) else - render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: deactivation_date_value, deactivation_date_type: params[:scheme][:deactivation_date_type].to_i } + render "toggle_active_confirm", locals: { action: "deactivate", deactivation_date: deactivation_date_value, deactivation_date_type: params[:scheme][:deactivation_date_type] } end end @@ -149,7 +150,7 @@ class SchemesController < ApplicationController def deactivation_date return if params[:scheme].blank? return @scheme.errors.add(:deactivation_date_type, message: I18n.t("validations.scheme.deactivation_date.not_selected")) if params[:scheme][:deactivation_date_type].blank? - return Time.utc(2022, 4, 1) if params[:scheme][:deactivation_date_type].to_i == 1 + return Time.utc(2022, 4, 1) if params[:scheme][:deactivation_date_type] == "default" return params[:scheme][:deactivation_date] if params[:scheme][:deactivation_date].present? day = params[:scheme]["deactivation_date(3i)"] diff --git a/app/views/schemes/toggle_active.html.erb b/app/views/schemes/toggle_active.html.erb index c2bf9c8b7..1c3c5abc9 100644 --- a/app/views/schemes/toggle_active.html.erb +++ b/app/views/schemes/toggle_active.html.erb @@ -15,11 +15,11 @@ hint: { text: "If the date is before 1 April 2022, select ‘From the start of the current collection period’ because the previous period has now closed."} do %> <%= govuk_warning_text text: "It will not be possible to add logs with this scheme if their tenancy start date is on or after the date you enter. Any existing logs may be affected." %> <%= f.govuk_radio_button :deactivation_date_type, - 1, + "default", label: { text: "From the start of the current collection period (1 April 2022)" } %> <%= f.govuk_radio_button :deactivation_date_type, - 2, + "other", label: { text: "For tenancies starting after a certain date" }, **basic_conditional_html_attributes({"deactivation_date" => ["other"]}, "scheme") do %> <%= f.govuk_date_field :deactivation_date,