10389 Posts in 2200 Topics by 1712 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1459 Views |
-
Userform State Dropdown

8 January 2011 at 1:01am Last edited: 8 January 2011 1:02am
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;
}
} -
Re: Userform State Dropdown

8 January 2011 at 8:27pm
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.
It is not already included. Not sure it's useful enough to be included in the default installation. Perhaps just keep it attached to the forum, you can optionally submit the field type as a module.
-
Re: Userform State Dropdown

8 January 2011 at 10:18pm
I added these userforms extension to my new github. Just learned how to commit + push changes today.
My additional custom fields are US States, and a Non Editable Field (with Default in the Extra Options)https://github.com/graphicagenda/Extending-Silverstripe-Module--Userform/tree/
My question to Willr is, how do we call an image for the field, the one with the pencil... without uploading it into the main userforms module?
-
Re: Userform State Dropdown

9 January 2011 at 7:02pm
You can define a function getIcon on your class which returns the path.
function getIcon() {
return 'yourmodule/images/foo.png';
} -
Re: Userform State Dropdown

13 March 2011 at 9:45pm
I believe it's
function Icon() {
return 'yourmodule/images/foo.png';
}And thanks Graphicator, I've been wanting that US States dropdown in Userforms forever.
-
Re: Userform State Dropdown

15 March 2011 at 10:00pm
SSViewer automatically trims any 'get' off for the templates.
| 1459 Views | ||
|
Page:
1
|
Go to Top |



