Code Monkey home page Code Monkey logo

silverstripe-phonenumber's Introduction

SilverStripe PhoneNumber module

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 - [email protected]

silverstripe-phonenumber's People

Contributors

lekoala avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

silverstripe-phonenumber's Issues

Silverstripe 5 compatible release

We're in the process of upgrading various sites to silverstripe 5 and some use this module. Are there any plans of releasing a tagged version of this module with SS5 support?

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.