Skip to content

Commit

Permalink
Release 0.0.2
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
Borales committed Mar 3, 2016
1 parent 6339ab4 commit 62b10f9
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,71 @@ to the `require` section of your `composer.json` file.

## Usage

Docs will be available soon...
![Phone input](screenshot.png "Phone input")

Using as an `ActiveField` widget with the preferred countries on the top:

```php
use borales\extensions\phoneInput\PhoneInput;

echo $form->field($model, 'phone_number')->widget(PhoneInput::className(), [
'jsOptions' => [
'preferredCountries' => ['no', 'pl', 'ua'],
]
]);
```

Using as a simple widget with the limited countries list:

```php
use borales\extensions\phoneInput\PhoneInput;

echo PhoneInput::widget([
'name' => 'phone_number',
'jsOptions' => [
'allowExtensions' => true,
'onlyCountries' => ['no', 'pl', 'ua'],
]
]);
```

Using phone validator in a model (validates the correct country code and phone format):

```php
namespace frontend\models;

use borales\extensions\phoneInput\PhoneInputValidator;

class Company extends Model
{
public $phone;

public function rules()
{
return [
[['phone'], 'string'],
[['phone'], PhoneInputValidator::className()],
];
}
}
```

Using phone behavior in a model (auto-formats phone string to the required phone format):

```php
namespace frontend\models;

use borales\extensions\phoneInput\PhoneInputBehavior;

class Company extends Model
{
public $phone;

public function behaviors()
{
return [
'phoneInput' => PhoneInputBehavior::className(),
];
}
}
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "borales/yii2-phone-input",
"version": "0.0.1",
"version": "0.0.2",
"description": "Yii2 International telephone numbers - Asset Bundle, Behavior, Validator, Widget",
"keywords": [
"yii2",
Expand Down
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 62b10f9

Please sign in to comment.