Answer the question
In order to leave comments, you need to log in
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
Judging by the sorts, you can try to ask ID
in options
: https://github.com/yiisoft/yii2/blob/master/framew...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question