module ActiveScaffold::Bridges::UsaStateSelect::UsaStateSelectOptionsHelpers

Constants

USASTATES

Public Instance Methods

usa_state_options_for_select(selected = nil, priority_states = nil) click to toggle source

Returns a string of option tags for the states in the United States. Supply a state name as +selected to have it marked as the selected option tag. Included also is the option to set a couple of priority_states in case you want to highligh a local area NOTE: Only the option tags are returned from this method, wrap it in a <select>

# File lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb, line 19
def usa_state_options_for_select(selected = nil, priority_states = nil)
  if priority_states
    state_options = options_for_select(priority_states + [['-------------', '']], :selected => selected, :disabled => '')
  else
    state_options = options_for_select([])
  end

  if priority_states && priority_states.include?(selected)
    state_options += options_for_select(USASTATES - priority_states, :selected => selected)
  else
    state_options += options_for_select(USASTATES, :selected => selected)
  end

  state_options
end