Q
Q
qasa555642016-06-25 14:50:27
Yii
qasa55564, 2016-06-25 14:50:27

How to generate a unique widget id?

Good afternoon. I have a form that is used multiple times on a page. In this form, I use the MaskedInput widget for the field. The problem is that the widget has several identical id for the field. How to make the widget generate an id or how to use the widget not by id, but by field name. Thank you!
Here is the code:

<?= $form->field($model, 'phone')->widget(MaskedInput::className(), [
    'mask' => '+9 (999) 999 99 99',	
])->textInput()
?>

<input type="text" id="form-phone" class="form-control" name="Form[phone]">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2016-08-07
@kimono

Judging by the sorts, you can try to ask IDin options: https://github.com/yiisoft/yii2/blob/master/framew...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question