lekoala/silverstripe-phonenumber

Format, store and validate phone number in SilverStripe

Fund package maintenance!
lekoala

Installs: 470

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 2

Open Issues: 1

Type:silverstripe-vendormodule

0.1 2016-03-25 08:00 UTC

This package is auto-updated.

Last update: 2021-01-07 07:59:11 UTC


README

Build Status scrutinizer Code coverage

Intro

Provide some helper services to deal with phone numbers in SilverStripe

This module integrates libphonenumber as the utility to parse and validate phonenumbers.

Most of the time, it's a good idea to set the country of the phone number. Otherwise, current locale will be used.

Sample code:

$phone = new PhoneField('phone', 'Phone number');
$phone->setCountryField('CountryCode');

$validator = ZenValidator::create();
$validator->setConstraint('phone', Constraint_remote::create('/__phonenumber/validate',null,array('data' => array('country' => 'BE'))));

This module also provide an extension to apply to dataobject, for example to members

SilverStripe\Security\Member:
  extensions:
    - LeKoala\PhoneNumber\PhoneNumberExtension

Phone DBField

You can set your DataObject db field to Phone or DBPhone::class

This will automatically scaffold a CountryPhoneField which is a combo field with a country dropdown (with list of prefixes) and a space for the field itself

Form fields

Two available fields:

  • PhoneField : a plain phone field that supports national and international numbers
  • CountryPhoneField : a combo field with a country dropdown + national phone number

Ajax validation and formatting

Expose ´__phonenumber/validate´ and ´__phonenumber/format´ endpoints for validation and formatting of phone numbers

Todo

None

Compatibility

Tested with 4.6 but should work on any ^4 projects

Maintainer

LeKoala - thomas@lekoala.be