module ActionView::Helpers::FormOptionsHelper

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/extensions/usa_state.rb, line 15
def usa_state_options_for_select(selected = nil, priority_states = nil)
  state_options = ""
  if priority_states
    state_options += options_for_select(priority_states, selected)
    state_options += "<option>-------------</option>\n"
  end

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

  return state_options
end
usa_state_select(object, method, priority_states = nil, options = {}, html_options = {}) click to toggle source

Return a full select and option tags for the given object and method, using #usa_state_options_for_select to generate the list of option <tags>.

# File lib/active_scaffold/extensions/usa_state.rb, line 6
def usa_state_select(object, method, priority_states = nil, options = {}, html_options = {})
  InstanceTag.new(object, method, self, options.delete(:object)).to_usa_state_select_tag(priority_states, options, html_options)
end