Git Product home page Git Product logo

silverware-countries's Introduction

SilverWare Countries Module

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 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.

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

Colin Tucker Praxis Interactive
Colin Tucker Praxis Interactive

License

BSD-3-Clause © Praxis Interactive

silverware-countries's People

Contributors

colintucker avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.