https://github.com/lekoala/silverstripe-phonenumber
Provide some helper services to deal with phone numbers in SilverStripe
https://github.com/lekoala/silverstripe-phonenumber
phonenumber silverstripe
Last synced: about 1 month ago
JSON representation
Provide some helper services to deal with phone numbers in SilverStripe
- Host: GitHub
- URL: https://github.com/lekoala/silverstripe-phonenumber
- Owner: lekoala
- License: mit
- Created: 2014-10-24T13:41:15.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-01-17T14:36:56.000Z (9 months ago)
- Last Synced: 2025-07-24T23:33:41.462Z (3 months ago)
- Topics: phonenumber, silverstripe
- Language: PHP
- Homepage:
- Size: 2.09 MB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# SilverStripe PhoneNumber module

[](https://scrutinizer-ci.com/g/lekoala/silverstripe-phonenumber/)
[](https://codecov.io/gh/lekoala/silverstripe-phonenumber)## 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:
```php
$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
```yml
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 5.x but should work on any ^4|^5 projects
## Maintainer
LeKoala - thomas@lekoala.be