Module: ActionView::Helpers::FormOptionsHelper
- Included in:
- InstanceTag
- Defined in:
- lib/active_scaffold/extensions/usa_state.rb
Constant Summary collapse
- USASTATES =
[["Alabama", "AL"], ["Alaska", "AK"], ["Arizona", "AZ"], ["Arkansas", "AR"], ["California", "CA"], ["Colorado", "CO"], ["Connecticut", "CT"], ["Delaware", "DE"], ["District of Columbia", "DC"], ["Florida", "FL"], ["Georgia", "GA"], ["Hawaii", "HI"], ["Idaho", "ID"], ["Illinois", "IL"], ["Indiana", "IN"], ["Iowa", "IA"], ["Kansas", "KS"], ["Kentucky", "KY"], ["Louisiana", "LA"], ["Maine", "ME"], ["Maryland", "MD"], ["Massachusetts", "MA"], ["Michigan", "MI"], ["Minnesota", "MN"], ["Mississippi", "MS"], ["Missouri", "MO"], ["Montana", "MT"], ["Nebraska", "NE"], ["Nevada", "NV"], ["New Hampshire", "NH"], ["New Jersey", "NJ"], ["New Mexico", "NM"], ["New York", "NY"], ["North Carolina", "NC"], ["North Dakota", "ND"], ["Ohio", "OH"], ["Oklahoma", "OK"], ["Oregon", "OR"], ["Pennsylvania", "PA"], ["Rhode Island", "RI"], ["South Carolina", "SC"], ["South Dakota", "SD"], ["Tennessee", "TN"], ["Texas", "TX"], ["Utah", "UT"], ["Vermont", "VT"], ["Virginia", "VA"], ["Washington", "WA"], ["Wisconsin", "WI"], ["West Virginia", "WV"], ["Wyoming", "WY"]]
Instance Method Summary collapse
-
#usa_state_options_for_select(selected = nil, priority_states = nil) ⇒ Object
Returns a string of option tags for the states in the United States.
-
#usa_state_select(object, method, priority_states = nil, options = {}, html_options = {}) ⇒ Object
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>.
Instance Method Details
#usa_state_options_for_select(selected = nil, priority_states = nil) ⇒ Object
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>
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_scaffold/extensions/usa_state.rb', line 15 def (selected = nil, priority_states = nil) = "" if priority_states += (priority_states, selected) += "<option>-------------</option>\n" end if priority_states && priority_states.include?(selected) += (USASTATES - priority_states, selected) else += (USASTATES, selected) end return end |
#usa_state_select(object, method, priority_states = nil, options = {}, html_options = {}) ⇒ Object
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>.
6 7 8 |
# File 'lib/active_scaffold/extensions/usa_state.rb', line 6 def usa_state_select(object, method, priority_states = nil, = {}, = {}) InstanceTag.new(object, method, self, .delete(:object)).to_usa_state_select_tag(priority_states, , ) end |