I added a Field for US States, and wondered where I can post this class for people in the US to add State dropdowns to their forms. Unless this is already included and i overlooked it.
moduledirectory/code/editor/EditableStateDropDown.php
class EditableStateDropDown extends EditableFormField {
static $singular_name = 'State Field';
static $plural_name = 'State Fields';
function getFormField() {
$labelField = new DropdownField($this->Name, $this->Title, GetStates::getStateDropDown());
$labelField->addExtraClass('FormState');
return $labelField;
}
}
moduledirectory/code/integration/GetStates .php
class GetStates {
protected static $us_stateCodes = array(
'None Selected' => "Select",
'Outside US' => "Outside US",
'AL' => "Alabama",
'AK' => "Alaska",
'Alberta' => "Alberta",
'AZ' => "Arizona",
'AR' => "Arkansas",
'Br. Columbia' => "Br. Columbia",
'CA' => "California",
'CO' => "Colorado",
'CT' => "Connecticut",
'DE' => "Delaware",
'DC' => "District of Columbia",
'FL' => "Florida",
'GA' => "Georgia",
'Guam' => "Guam",
'HI' => "Hawaii",
'ID' => "Idaho",
'IL' => "Illinois",
'IN' => "Indiana",
'IA' => "Iowa",
'KS' => "Kansas",
'KY' => "Kentucky",
'LO' => "Louisiana",
'ME' => "Maine",
'Manitoba' => "Manitoba",
'MD' => "Maryland",
'MA' => "Massachusetts",
'MI' => "Michigan",
'MN' => "Minnesota",
'MS' => "Mississippi",
'MO' => "Missouri",
'MT' => "Montana",
'NE' => "Nebraska",
'NV' => "Nevada",
'New Brunswick' => "New Brunswick",
'NH' => "New Hampshire",
'NJ' => "New Jersey",
'NM' => "New Mexico",
'NY' => "New York",
'Newfoundland' => "Newfoundland",
'NC' => "North Carolina",
'ND' => "North Dakota",
'Nova Scotia' => "Nova Scotia",
'OH' => "Ohio",
'OK' => "Oklahoma",
'Ontaria' => "Ontario",
'OR' => "Oregon",
'PA' => "Pennsylvania",
'Pr. Edward Isl.' => "Pr. Edward Island",
'PR' => "Puerto Rico",
'Quebec' => "Quebec",
'RI' => "Rhode Island",
'Saskatchewan' => "Saskatchewan",
'SC' => "South Carolina",
'SD' => "South Dakota",
'TN' => "Tennessee",
'TX' => "Texas",
'UT' => "Utah",
'VT' => "Vermont",
'VA' => "Virginia",
'WA' => "Washington",
'WV' => "West Virginia",
'WI' => "Wisconsin",
'WY' => "Wyoming"
);
/**
* Returns an array of State Names
*/
static function getStateDropDown() {
$dropdown = GetStates::$us_stateCodes;
asort($dropdown);
return $dropdown;
}
}