Download the PHP package xini/silverstripe-international-phone-number-field without Composer
On this page you can find all versions of the php package xini/silverstripe-international-phone-number-field. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xini/silverstripe-international-phone-number-field
More information about xini/silverstripe-international-phone-number-field
Files in xini/silverstripe-international-phone-number-field
Package silverstripe-international-phone-number-field
Short Description Adds a phone filed using Google's libphonenumber.
License BSD-3-Clause
Informations about the package silverstripe-international-phone-number-field
International Phone Number Field
Introduction
Adds a database and form field for international phone numbers using Google's libphonenumber and the intl-tel-input plugin.
IP Geo Location services supported:
- ipstack.com
- ipinfo.io
- ipgeolocation
- freegeoip (default)
Requirements
- Silverstripe ^5
-
libphonenumber port for PHP ^8
Note: this version is compatible with SilverStripe 5. For SilverStripe 4, please see the 4 release line.
Installation
Install the module using composer:
Then run dev/build.
Usage
Database field
This module provides a database field to be used for data objects:
This stores the phone number in the database as a varchar.
In the CMS the data type Phone
renders as a InternationalPhoneNumberField
.
In templates, the following formatting functions are available:
$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.
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:
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 tofalse
.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 tofalse
, all countries are listed.preferred_countries
: Array of country codes pushed to the top of the dropdown list. Defaults tofalse
, all countries are listed alphabetically.excluded_countries
: Array of country codes to be excluded from the dropdown lost. Defaults tofalse
, all countries are listed.
License
BSD 3-Clause License, see License
All versions of silverstripe-international-phone-number-field with dependencies
silverstripe/vendor-plugin Version ^2
giggsey/libphonenumber-for-php Version ^8.13.7