A
A
Anatoly2015-07-11 13:34:09
Yii
Anatoly, 2015-07-11 13:34:09

Yii2 Form ActiveForm. How to transform the phone input field?

There is here such form: 6f4c64b11ba041f6979501983a7062cc.png
It is necessary for me that at a mouse click there was a transformation of such type. That is, a phone number template was displayed:
2c971798d262455095ccfa3a857171d5.png94720aaa3add44948add224a5d040649.png
I would be very grateful for your help.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
antonkabaev, 2015-08-21
@Benjamin_Button

print $form->field($model, 'phone')->label(false)->widget(\yii\widgets\MaskedInput::className(), [
  'mask' => '+7 (999) 999 99 99',
])->textInput(['placeholder' => $model->getAttributeLabel('phone')]);

// ну или коротко..
print $form->field($model, 'phone')->widget(\yii\widgets\MaskedInput::className(), [
  'mask' => '+7 (999) 999 99 99',
]);

P
Pavel Gogolinsky, 2015-07-11
@gogolinsky

www.yiiframework.com/doc-2.0/yii-widgets-maskedinp...

A
AlikDex, 2015-07-11
@AlikDex

copy the function from the site where you saw it. business then =)

V
Vladimir, 2015-07-11
@de1vin

I think it's about https://github.com/RobinHerbots/jquery.inputmask
Like this:
$("input.phone").inputmask("+7 (999) 999-9999");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question