SilverWare Countries Module.

Installs: 4 972

Dependents: 3

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 2

Open Issues: 3


1.0.2 2017-10-08 06:11 UTC

This package is not auto-updated.

Last update: 2024-05-24 23:50:31 UTC


Latest Stable Version Latest Unstable Version License

Provides a CountryDropdownField for use in SilverStripe v4 forms.



SilverStripe decided to remove CountryDropdownField from framework in v4, which can be a pretty handy field when you need an international address entered into a form. This module provides a replacement field, with similar configuration options to the original.



Installation is via Composer:

$ composer require silverware/countries


As with all SilverStripe modules, configuration is via YAML. There are three configuration options available for CountryDropdownField:

  • default_to_locale - default setting is false; if set to true, the default value for the field will be based on either the locale of the current user, or the default locale for the app (obtained from i18n).
  • default_country - default setting is null; defines the country code to use as the default value if default_to_locale is set to false.
  • invalid_countries - defines a list of country codes which are considered invalid and are removed from the default source data.

Differences from Original Class

Note: default_to_locale and default_country in this module are different from the original SilverStripe field. The original class had default_to_locale set to true, and default_country set to NZ.

You can still set these defaults through configuration if you wish, however I figured it would be better to not make assumptions about locale or country by default. More often than not these defaults were overridden for projects using the original field.


To make use of the field within your code, simply use the class within the header of your file:

use SilverWare\Countries\Forms\CountryDropdownField;

You can then create an instance of the field within your form code:

CountryDropdownField::create('MyCountryCode', 'Country');


Please use the GitHub issue tracker for bug reports and feature requests.


Your contributions are gladly welcomed to help make this project better. Please see contributing for more information.


Colin Tucker Praxis Interactive
Colin Tucker Praxis Interactive


BSD-3-Clause © Praxis Interactive