Skip to content

Commit

Permalink
Fix site edit when coordinates not present
Browse files Browse the repository at this point in the history
  • Loading branch information
joeroe committed Nov 20, 2023
1 parent 136258b commit caa4c0b
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions app/views/sites/_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,14 @@
construct the label and wrapper HTML manually here %>
<div class="mb-3">
<%= f.label :country_code, "Country", class: "form-label" %>
<%
<%=
country_select_options = { include_blank: na_value }
if @site.country_from_coordinates.present?
country_guess = @site.country_from_coordinates.alpha2
else
country_guess = nil
country_select_options[:priority_countries] = [@site.country_from_coordinates.alpha2]
end
%>
<%= f.country_select :country_code,
{
include_blank: na_value,
priority_countries: [country_guess]
},
{ data: { controller: 'tom-select' } }

f.country_select :country_code, country_select_options,
{ data: { controller: 'tom-select' } }
%>
</div>

Expand Down

0 comments on commit caa4c0b

Please sign in to comment.