Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

drop down with list values in forms


Go to End


1763 Views

Avatar
S0crates9

27 Posts

23 June 2009 at 7:56am

Edited: 23/06/2009 7:58am

I've seen this in the e-commerce module and wanted to know how to use it in the CMS for custom drop-downs:

if( ! $fields->fieldByName( 'Country' ) ) $fields->push(new DropdownField('Country', 'Country', Geoip::getCountryDropDown()));
}

This one clearly calls a function to get the GEO target, but how do I add a list of values here? Oh, and for this example as well, how do I add a default value if nothing is found?

Thanks for any hep in advance!