yii2-phone-input
yii2-phone-input copied to clipboard
No field posted when using intlTelInput
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 maybe it's a silly question, but do you have this column (phone) in your db table?
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 is this issue still relevant?
@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'], ] ]) ?>