In a single view page,i have 2 active forms.the First active form 's datepicker is working.The second active form’s datepicker is not working…Please help me to rectify this problem.My Code goes like this
<div class="patient-booking-form">
<h1>Add appointments</h1>
<div class="row">
<input type="radio" id="ex" name="exist" value=0> <label class="check" for="fresh" style="margin-right:30px; margin-left:5px; font-weight:normal;">Existing</label>
<input type="radio" id="ne" name="exist" value=1 checked> <label class="check" for="revisit" style="margin-left:5px; font-weight:normal;" >New</label>
</div>
<?php $form = ActiveForm::begin([
'id'=>'existing',
]);
?>
<?php
$user=Doctors::find()->where('user_id=:user',['user'=>Yii::$app->session->get('user_id')])->one();
?>
<div id=patient_id>
<?php echo $form->field($model, 'patient_id')->textInput(
[ 'onchange'=>'
$.get( "'.Url::toRoute('doctors/patient_search').'", { id: $(this).val() } )
.done(function( data )
{
$( "#details" ).html( data );
});
']);
?>
</div>
<div id="details">
</div>
<label>Location</label>
<?php
$location=ArrayHelper::map(DoctorAdditionalPractice::find()->where('doctor_id=:doctor',['doctor'=>$id])->all(), 'id','name');
echo $form->field($model,'doc_practice_locatoin_id')->dropDownList($location,['prompt'=>'select'])->label('');
?>
<?= $form->field($model, 'booking_date')->widget(DatePicker::classname(), [
'options' => ['placeholder' => ''],
'readonly' => false,
'pluginOptions' => [
'autoclose' => true,
'format' => 'dd-mm-yyyy',
'value'=>date('d-m-Y'),
'todayHighlight' => true,
'todayBtn' => true,
'pickerPosition'=> "bottom-right",
]
]);
?>
<?php
echo $form->field($model, 'visit')->dropDownList(
[0=> 'visit', 1=> 'revisit'] ,["class"=>"form-control","prompt"=>"select"]);
?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-default ' : 'btn btn-default','name'=>'submit']) ?>
</div>
<?php ActiveForm::end(); ?>
<!-- Add new Patient -->
<?php $form = ActiveForm::begin([
'id'=>'new',
]);
?>
<div id=patient_name>
<?php
echo $form->field($new_patient,'name')->textInput();
?>
</div>
<div id=patient_email>
<?php
echo $form->field($new_patient,'email')->textInput();
?>
</div>
<div id=patient_phone>
<?php
echo $form->field($new_patient,'phone2')->textInput();
?>
</div>
<label>Location</label>
<?php
$location=ArrayHelper::map(DoctorAdditionalPractice::find()->where('doctor_id=:doctor',['doctor'=>$id])->all(), 'id','name');
echo $form->field($model1,'doc_practice_locatoin_id')->dropDownList($location,['prompt'=>'select'])->label('');
?>
<?= $form->field($model1, 'booking_date')->widget(DatePicker::classname(), [
'options' => ['placeholder' => ''],
'readonly' => false,
'pluginOptions' => [
'autoclose' => true,
'format' => 'dd-mm-yyyy',
'value'=>date('d-m-Y'),
//~ 'endDate'=>date("d-m-Y",strtotime("+2 month")),
'todayHighlight' => true,
'todayBtn' => true,
'pickerPosition'=> "bottom-right",
]
]);
?>
<?php
echo $form->field($model1, 'visit')->dropDownList(
[0=> 'visit', 1=> 'revisit'] ,["class"=>"form-control","prompt"=>"select"]);
?>
<div class="form-group">
<?= Html::submitButton($model1->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model1->isNewRecord ? 'btn btn-default ' : 'btn btn-default','name'=>'submits']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>