Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Ruby U.S. States Drop Down (Abbreviated) (See related posts)

Ruby hash of abbreviated states for <select> field in form. If you don't do the input field with a rails form helper and use regular html instead rails won't wrap the field with the <div class="fieldWithErrors"> tag when validation fails. It's easier to fix validation this way rather than dig through the base validation code and keeps your forms cleaner anyways.

			<%= f.select :state, ['AK',
			'AL',
			'AR',
			'AZ',
			'CA',
			'CO',
			'CT',
			'DC',
			'DE',
			'FL',
			'GA',
			'HI',
			'IA',
			'ID',
			'IL',
			'IN',
			'KS',
			'KY',
			'LA',
			'MA',
			'MD',
			'ME',
			'MI',
			'MN',
			'MO',
			'MS',
			'MT',
			'NC',
			'ND',
			'NE',
			'NH',
			'NJ',
			'NM',
			'NV',
			'NY',
			'OH',
			'OK',
			'OR',
			'PA',
			'RI',
			'SC',
			'SD',
			'TN',
			'TX',
			'UT',
			'VA',
			'VT',
			'WA',
			'WI',
			'WV',
			'WY'], 
			:include_blank => true %>

You need to create an account or log in to post comments to this site.


Click here to browse all 7305 code snippets

Related Posts