Borales / yii2-phone-input

Yii2 International telephone numbers
Other
135 stars 55 forks source link

improve the code example #27

Open michaelnguyen2021 opened 7 years ago

michaelnguyen2021 commented 7 years ago

Great extension but I have difficult time to follow your example to make it work for my use case

In your code example, you have 'phone_number', 'phone', and 'phoneInput' . They are confusing as there is little explanation on what they do.

My use case is I have 'primary_phone' and 'secondary_phone', after trial and error I got it working with the following

/** Model **/
use borales\extensions\phoneInput\PhoneInputValidator;
class Student extends ActiveRecord
{
    public $phone; // must declare other this extension wont work 

    public function behaviors()
    {
        return [
           PhoneInputBehavior::className(),
        ];
    }

    public function rules()
    {
        return [
            [['primary_phone', 'secondary_phone'], 'string', 'max' => 255],
            [['primary_phone', 'secondary_phone'], PhoneInputValidator::className()],
    }
}