yii2-phone-input icon indicating copy to clipboard operation
yii2-phone-input copied to clipboard

No field posted when using intlTelInput

Open jeesus opened this issue 9 years ago • 4 comments

Hey

Really nice plugin you have here. But I'm having difficulties using it. The thing is that whenever I use this extension with ActiveForm in Yii2, the field is never posted. I printed out Yii::$app->request->post() just to be sure and the phone field is always missing. Previously I used the original JS plugin and had the same problem, which I never figured out.

This is my code in model:

    public function behaviors()
    {
        return [
            'phone' => PhoneInputBehavior::className(),
        ];
    }

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

The view:

    $form->field($model, 'phone')->widget(PhoneInput::className(), [
                    'jsOptions' => [
                        'preferredCountries' => ['ee'],
                    ],
                    'options' => ['class' => 'form-control'],
                ]);

One thing more... when I won't define $phone as public variable in model, the initial flag in the input field is not appearing. Defining it won't solve the general problem though. Any ideas?

jeesus avatar Apr 13 '16 14:04 jeesus

@jeesus maybe it's a silly question, but do you have this column (phone) in your db table?

Borales avatar Apr 14 '16 10:04 Borales

Yes, I do. When using regular ActiveForm textInput(), the field gets saved properly. I'll look into it again later today, maybe I can figure out something.

jeesus avatar Apr 14 '16 11:04 jeesus

@jeesus is this issue still relevant?

Borales avatar Nov 11 '16 17:11 Borales

@Borales I have the same problem, POST doesn't consist phone field;

= $form->field($model, 'phone')->widget(PhoneInput::className(), [ 'options' => ['class' => 'form-control'], 'jsOptions' => [ 'preferredCountries' => ['ua', 'ru'], ] ]) ?>

forzac avatar Apr 21 '17 17:04 forzac