Borales / yii2-phone-input

Yii2 International telephone numbers
Other
133 stars 54 forks source link

No field posted when using intlTelInput #11

Open jeesus opened 8 years ago

jeesus commented 8 years ago

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?

Borales commented 8 years ago

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

jeesus commented 8 years ago

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.

Borales commented 7 years ago

@jeesus is this issue still relevant?

forzac commented 7 years ago

@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'], ] ]) ?>