SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sorting us_state_options_for_select() options on the full state name

    This is a little pickle I'm in and I was hopping that one of you folks could help me

    I'm trying to use this ROR call
    Code:
    <%= us_state_options_for_select(text) %>
    but the states are sorted on the abbreviations, even though the actual states are displayed

    so in html
    I've got
    Code:
    <option value="AK">Alaska</option>
    <option value="AL">Alabama</option>
    <option value="AR">Arkansas</option>
    <option value="AZ">Arizona</option>
    <option value="CA">California</option>

    I want Arizona to come before Arkansas, Alabama before Alaska ... etc (as it should alphabetically) is this possible?

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    us_state_options_for_select is not a standard Rails method (it doesn't appear in the Rails API reference)

    Looking at this reference, it appears to be a plug-in. You are going to need to look at the documentation for that plug-in, contact the author of the plug-in or tweak the code yourself. It should just be a case of sorting the array of states, but without the code in front of me, its not possible to tell you the best place to do that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •