1. Go to this page and download the library: Download borales/yii2-phone-input library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
namespace frontend\models;
use borales\extensions\phoneInput\PhoneInputValidator;
class Company extends Model
{
public $phone;
public function rules()
{
return [
[['phone'], 'string'],
[['phone'], PhoneInputValidator::className()],
];
}
}
namespace frontend\models;
use borales\extensions\phoneInput\PhoneInputValidator;
class Company extends Model
{
public $phone;
public function rules()
{
return [
[['phone'], 'string'],
// [['phone'], PhoneInputValidator::className(), 'region' => 'UA'],
[['phone'], PhoneInputValidator::className(), 'region' => ['PL', 'UA']],
];
}
}
namespace frontend\models;
use borales\extensions\phoneInput\PhoneInputBehavior;
class Company extends Model
{
public $phone;
public function behaviors()
{
return [
'phoneInput' => PhoneInputBehavior::className(),
];
}
}
namespace frontend\models;
use borales\extensions\phoneInput\PhoneInputBehavior;
class Company extends Model
{
public $phone;
public $countryCode;
public function behaviors()
{
return [
[
'class' => PhoneInputBehavior::className(),
'countryCodeAttribute' => 'countryCode',
],
];
}
}
bash
$ php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.