I’m using a Timezone field in SimpleForm,
my requirement is to have the US timezones + London shown at the top as ‘priority’ values.
it is in my form like this:
<%= p.input :time_zone, :label => "Time Zone", :priority => (ActiveSupport::TimeZone.us_zones << ActiveSupport::TimeZone['London'])%>
This works, but it adds another copy of ‘London’ each time you reload the form. (I can see why as it adds the ‘London’ value to the predefined array, BUT:
I’ve tried adding this to my controller:
@priority_time_zones = ActiveSupport::TimeZone.us_zones
@priority_time_zones << ActiveSupport::TimeZone['London']
And then changing the form to:
<%= p.input :time_zone, :label => "Time Zone", :priority => @priority_time_zones %>
But this doesn’t fix it (oddly), don’t understand why it keeps adding another ‘London’ on each reload.
Any thoughts?? thnx
Need to use @priority_time_zones = ActiveSupport::TimeZone.us_zones.dup to duplicate the array, otherwise I’m still updating the original list