2017 © Pedro Peláez
 

silverstripe-module silverstripe-international-phone-number-field

Adds a phone filed using Google's libphonenumber.

image

xini/silverstripe-international-phone-number-field

Adds a phone filed using Google's libphonenumber.

  • Tuesday, June 6, 2017
  • by xini
  • Repository
  • 1 Watchers
  • 2 Stars
  • 43 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 5 % Grown

The README.md

International Phone Number Field

Version License, (*1)

Introduction

Adds a database and form field for international phone numbers using Google's libphonenumber and the intl-tel-input plugin., (*2)

IP Geo Location services supported: * ipstack.com * ipinfo.io * ipgeolocation * freegeoip (default), (*3)

Requirements

Installation

Install the module using composer:, (*6)

composer require innoweb/silverstripe-international-phone-number-field dev-master

Then run dev/build., (*7)

Usage

Database field

This module provides a database field to be used for data objects:, (*8)

private static $db = [
    ...
    'PhoneNumber' => 'Phone',
    ...
];

This stores the phone number in the database as a varchar., (*9)

In the CMS the data type Phone renders as a InternationalPhoneNumberField., (*10)

In templates, the following formatting functions are available:, (*11)

  • $PhoneNumber.International: Returns the phone number in international format, e.g. "+41 44 668 1800"
  • $PhoneNumber.National: Returns the phone number in national format, e.g. "044 668 1800"
  • $PhoneNumber.E164: Returns the phone number in international format, but with no formatting applied, e.g. "+41446681800"
  • $PhoneNumber.URL or $PhoneNumber.RFC3966: Returns the phone number in international format, but with all spaces and other separating symbols replaced with a hyphen, and with any phone number extension appended with ";ext=". It also will have a prefix of "tel:" added, e.g. "tel:+41-44-668-1800".

Form field

The InternationalPhoneNumberField can be used for any Varchar field storing a phone number., (*12)

Configuration

To set the field to use the user's current location as default and customise the field, you can configure the following options for the InternationalPhoneNumberField class:, (*13)

  • geolocation_service: Uses IP location to determine the current users's country code. This can be 'ipstack', 'ipinfo', 'ipgeolocation' or 'freegeoip'. Defaults to 'freegeoip'.
  • geolocation_api_key: API key for ipstack.com, ipinfo.io or ipgeolocation. Defaults to false.
  • geolocation_protocol: Protocol to be used to connecto to geolocation service. Defaults to 'https'.
  • initial_country: Country code for initially shown country in the phone number field. Defaults to 'auto', in which case the location is determined using geolocation if that's set up.
  • only_countries: Array of country codes available for selection. Defaults to false, all countries are listed.
  • preferred_countries: Array of country codes pushed to the top of the dropdown list. Defaults to false, all countries are listed alphabetically.
  • excluded_countries: Array of country codes to be excluded from the dropdown lost. Defaults to false, all countries are listed.

License

BSD 3-Clause License, see License, (*14)

The Versions

06/06 2017

dev-master

9999999-dev

Adds a phone filed using Google's libphonenumber.

  Sources   Download

MIT

The Requires

 

form silverstripe field phone

06/06 2017

2.0.2

2.0.2.0

Adds a phone filed using Google's libphonenumber.

  Sources   Download

MIT

The Requires

 

form silverstripe field phone

08/05 2017

2.0.1

2.0.1.0

Adds a phone filed using Google's libphonenumber.

  Sources   Download

MIT

The Requires

 

form silverstripe field phone

24/04 2017

2.0.0

2.0.0.0

Adds a phone filed using Google's libphonenumber.

  Sources   Download

MIT

The Requires

 

form silverstripe field phone

22/06 2016

1.1.0

1.1.0.0

Adds a phone filed using Google's libphonenumber.

  Sources   Download

MIT

The Requires

 

form silverstripe field phone

07/02 2016

1.0.2

1.0.2.0

Adds a phone filed using Google's libphonenumber.

  Sources   Download

MIT

The Requires

 

form silverstripe field phone

30/01 2016

1.0.1

1.0.1.0

Adds a phone filed using Google's libphonenumber.

  Sources   Download

MIT

The Requires

 

form silverstripe field phone

30/01 2016

1.0.0

1.0.0.0

Adds a phone filed using Google's libphonenumber.

  Sources   Download

The Requires

 

form silverstripe field phone