2017 © Pedro Peláez
 

yii2-component yii2-phone

Yii2 phone formatter and validator.

image

floor12/yii2-phone

Yii2 phone formatter and validator.

  • Sunday, July 29, 2018
  • by floor12
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

yii2-phone

Formatter and validator form phone numbers, (*1)

Этот файл доступен на русском языке., (*2)

Build Status Code quality score Code Coverage Latest Stable Version Total Downloads License, (*3)

Installation

To use this extension run this command:, (*4)

bash $ composer require floor12/yii2-phone or add this to the require section of your composer.json. json "floor12/yii2-phone": "dev-master", (*5)

Usage

This extension allows to validate phone numbers and save only numbers in db without any formatting. It also include simple formatter to render formatted phone numbers as string or html <a href='tel:'> tag., (*6)

Phone validation

To store phone number in database, ActiveRecord model database field should be VARCHAR(15)., (*7)

The validator has backend and frontend (js) validation. To validate your field, add floor12\phone\PhoneValidator to ActiveRecord::rules() action like this:, (*8)

use floor12\phone\PhoneValidator;
use yii\base\Model;

class User extends Model
{

    public $phone;

    public function rules()
    {
        return [
            ['phone', PhoneValidator::class]
        ];
    }
}

Phone formatting

Class floor12\phone\PhoneFormatter allows to render phone number as formatted string or as html <a href="tel:">, and has two static methods: - PhoneFormatter::format($phone) - PhoneFormatter::a($phone,array $options= []), (*9)

Formatting examples, (*10)

echo PhoneFormatter::format(79461234565);                       # +7 (946) 123-45-65
echo PhoneFormatter::a(79461234565);                            # <a href='tel:+79461234565'>+7 (946) 123-45-65</a>
echo PhoneFormatter::a(79461234565,['class'=>'phone-link']);    # <a href='tel:+79461234565' class='phone-link'>+7 (946) 123-45-65</a>

The Versions

29/07 2018

dev-master

9999999-dev

Yii2 phone formatter and validator.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar floor12

yii2 validator yii yii 2 formatter phone floor12 yii2 module

29/07 2018

1.0.2

1.0.2.0

Yii2 phone formatter and validator.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar floor12

yii2 validator yii yii 2 formatter phone floor12 yii2 module

28/07 2018

1.0.1

1.0.1.0

Yii2 phone formatter and validator.

  Sources   Download

MIT

The Requires

 

by Avatar floor12

yii2 validator yii yii 2 formatter phone floor12 yii2 module

27/07 2018

1.0.0

1.0.0.0

Yii2 phone formatter and validator.

  Sources   Download

MIT

The Requires

 

by Avatar floor12

yii2 validator yii yii 2 formatter phone floor12 yii2 module