From 1e1b5b789990cfab65d24a0bd8343b5ea3ab3d72 Mon Sep 17 00:00:00 2001 From: Samuel Young Date: Fri, 5 Dec 2025 17:37:35 +0000 Subject: [PATCH] CLDC-4129: Add a default option for location search prevents the first option from being selected by default --- app/models/form/lettings/questions/location_id_search.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/form/lettings/questions/location_id_search.rb b/app/models/form/lettings/questions/location_id_search.rb index ecba28c38..5e1734b51 100644 --- a/app/models/form/lettings/questions/location_id_search.rb +++ b/app/models/form/lettings/questions/location_id_search.rb @@ -16,7 +16,7 @@ class Form::Lettings::Questions::LocationIdSearch < ::Form::Question end def answer_options - answer_opts = {} + answer_opts = { "" => "Select an option" } return answer_opts unless ActiveRecord::Base.connected? Location.visible.started_in_2_weeks.select(:id, :postcode, :name).each_with_object(answer_opts) do |location, hsh| @@ -29,7 +29,7 @@ class Form::Lettings::Questions::LocationIdSearch < ::Form::Question return {} unless lettings_log.scheme scheme_location_ids = lettings_log.scheme.locations.visible.confirmed.pluck(:id) - answer_options.select { |k, _v| scheme_location_ids.include?(k.to_i) }.to_h + answer_options.select { |k, _v| scheme_location_ids.include?(k.to_i) or k == "" }.to_h end def hidden_in_check_answers?(lettings_log, _current_user = nil)