Answer the question
In order to leave comments, you need to log in
how to make multiple datepicker in yii2?
Hello, I need your help. I have a form to fill out a plan. This plan includes milestones. The stages consist of a description title and a date. problem with filling in the date. the first time the datepicker works, but the subsequent ones do not, I need it to work for the next steps. What should I do.
form screen form
code
<div class="ag_1_1">
<div class="ag_3">План достижения цели</div>
<div class="stage">
<div class="ag_1_2"><?= $form->field($stage, '[]title')->textInput(['class'=>'input_goal','placeholder'=>'Название этапа'])->label(false) ?></div>
<div class="ag_1_2"><?= $form->field($stage, '[]description')->textarea(['class'=>'input_goal','placeholder'=>'Описание этапа'])->label(false) ?></div>
<ul class="ag_8">
<li class="ag_l"><img src="img/icon/leveldown.svg" alt=""/></li>
<li class="ag_ac"><?= $form->field($stage, '[]date_finish_stage')->widget(BootstrapDatepicker::className(['type'=>BootstrapDatepicker::TYPE_RANGE]))->label() ?></li>
</ul>
</div>
<div class="ag_2_1" onclick="$('.ag_1_1').find('.stage').append($('.stage').html());">Добавить этап</div>
</div>
Answer the question
In order to leave comments, you need to log in
Good evening.
You need to re-initialize the calendars each time you add the DatePicker.
Something like this:
// сначала удаляем все datepicker
form.find('.hasDatepicker').datepicker('destroy');
// затем заново всё инициализируем
$('#testForm').find('input[data-picker=datepicker]').datepicker()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question