silverware / countries
SilverWare Countries Module.
Installs: 5 283
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 2
Open Issues: 3
Type:silverstripe-vendormodule
Requires
- php: >=5.6.0
- silverstripe/framework: ^4@dev
This package is not auto-updated.
Last update: 2024-10-26 01:44:52 UTC
README
Provides a CountryDropdownField
for use in SilverStripe v4 forms.
Contents
Background
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.
Requirements
Installation
Installation is via Composer:
$ composer require silverware/countries
Configuration
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 fromi18n
).default_country
- default setting is null; defines the country code to use as the default value ifdefault_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.
Usage
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');
Issues
Please use the GitHub issue tracker for bug reports and feature requests.
Contribution
Your contributions are gladly welcomed to help make this project better. Please see contributing for more information.
Maintainers
License
BSD-3-Clause © Praxis Interactive