lekoala/silverstripe-phonenumber
最新稳定版本:1.1.0
Composer 安装命令:
composer require lekoala/silverstripe-phonenumber
包简介
Format, store and validate phone number in SilverStripe
README 文档
README
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 5.x but should work on any ^4|^5 projects
Maintainer
LeKoala - thomas@lekoala.be
统计信息
- 总下载量: 2.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-16