Date Picker is not working

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">

&lt;h1&gt;Add appointments&lt;/h1&gt;





	&lt;div class=&quot;row&quot;&gt;


		&lt;input type=&quot;radio&quot;  id=&quot;ex&quot; name=&quot;exist&quot; value=0&gt; &lt;label class=&quot;check&quot; for=&quot;fresh&quot; style=&quot;margin-right:30px; margin-left:5px; font-weight:normal;&quot;&gt;Existing&lt;/label&gt;


        &lt;input type=&quot;radio&quot;  id=&quot;ne&quot; name=&quot;exist&quot; value=1 checked&gt; &lt;label class=&quot;check&quot; for=&quot;revisit&quot; style=&quot;margin-left:5px; font-weight:normal;&quot; &gt;New&lt;/label&gt;


	&lt;/div&gt;


			


	&lt;?php &#036;form = ActiveForm::begin([


					'id'=&gt;'existing',


					


									]); 


	?&gt;


	&lt;?php


		&#036;user=Doctors::find()-&gt;where('user_id=:user',['user'=&gt;Yii::&#036;app-&gt;session-&gt;get('user_id')])-&gt;one();


	?&gt;


	&lt;div id=patient_id&gt;	


		&lt;?php  echo &#036;form-&gt;field(&#036;model, 'patient_id')-&gt;textInput(


					[ 'onchange'=&gt;'


					 &#036;.get( &quot;'.Url::toRoute('doctors/patient_search').'&quot;, { id: &#036;(this).val() } )


                      .done(function( data )


						{


                          &#036;( &quot;#details&quot; ).html( data );


                        });


                    ']);


          ?&gt; 


	&lt;/div&gt;


	&lt;div id=&quot;details&quot;&gt;


						


	&lt;/div&gt;





	&lt;label&gt;Location&lt;/label&gt;


			&lt;?php


				&#036;location=ArrayHelper::map(DoctorAdditionalPractice::find()-&gt;where('doctor_id=:doctor',['doctor'=&gt;&#036;id])-&gt;all(), 'id','name');


						echo &#036;form-&gt;field(&#036;model,'doc_practice_locatoin_id')-&gt;dropDownList(&#036;location,['prompt'=&gt;'select'])-&gt;label('');


					


			?&gt;


			&lt;?= &#036;form-&gt;field(&#036;model, 'booking_date')-&gt;widget(DatePicker::classname(), [


						'options' =&gt; ['placeholder' =&gt; ''],


						'readonly'	=&gt; false,


						'pluginOptions' =&gt; [


						'autoclose' =&gt; true,


						'format' =&gt; 'dd-mm-yyyy',


						'value'=&gt;date('d-m-Y'),


						'todayHighlight' =&gt; true,


						'todayBtn'	=&gt; true,


						'pickerPosition'=&gt; &quot;bottom-right&quot;,


						]


						]);


			?&gt;





		


			&lt;?php 


					echo &#036;form-&gt;field(&#036;model, 'visit')-&gt;dropDownList(


					[0=&gt; 'visit', 1=&gt; 'revisit'] ,[&quot;class&quot;=&gt;&quot;form-control&quot;,&quot;prompt&quot;=&gt;&quot;select&quot;]);


			?&gt;


			


			&lt;div class=&quot;form-group&quot;&gt;


					&lt;?= Html::submitButton(&#036;model-&gt;isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' =&gt; &#036;model-&gt;isNewRecord ? 'btn btn-default ' : 'btn btn-default','name'=&gt;'submit']) ?&gt;


			&lt;/div&gt;


		


	&lt;?php ActiveForm::end(); ?&gt;

<!-- Add new Patient -->

	&lt;?php &#036;form = ActiveForm::begin([


		'id'=&gt;'new',


	]); 


	


	?&gt;


	


			&lt;div id=patient_name&gt;	


					&lt;?php


					echo &#036;form-&gt;field(&#036;new_patient,'name')-&gt;textInput();


					?&gt;


			&lt;/div&gt;


			&lt;div id=patient_email&gt;	


					&lt;?php


					echo &#036;form-&gt;field(&#036;new_patient,'email')-&gt;textInput();


					?&gt;


			&lt;/div&gt;


			&lt;div id=patient_phone&gt;	


					&lt;?php


					echo &#036;form-&gt;field(&#036;new_patient,'phone2')-&gt;textInput();


					?&gt;


			&lt;/div&gt;


	


					&lt;label&gt;Location&lt;/label&gt;


					&lt;?php


					&#036;location=ArrayHelper::map(DoctorAdditionalPractice::find()-&gt;where('doctor_id=:doctor',['doctor'=&gt;&#036;id])-&gt;all(), 'id','name');


						echo &#036;form-&gt;field(&#036;model1,'doc_practice_locatoin_id')-&gt;dropDownList(&#036;location,['prompt'=&gt;'select'])-&gt;label('');


					


					?&gt;


					


				


					&lt;?= &#036;form-&gt;field(&#036;model1, 'booking_date')-&gt;widget(DatePicker::classname(), [


						'options' =&gt; ['placeholder' =&gt; ''],


						'readonly'	=&gt; false,


						'pluginOptions' =&gt; [


						'autoclose' =&gt; true,


						'format' =&gt; 'dd-mm-yyyy',


						'value'=&gt;date('d-m-Y'),


						//~ 'endDate'=&gt;date(&quot;d-m-Y&quot;,strtotime(&quot;+2 month&quot;)),


						'todayHighlight' =&gt; true,


						'todayBtn'	=&gt; true,


						'pickerPosition'=&gt; &quot;bottom-right&quot;,


						]


						]);


					?&gt;


					





		


				&lt;?php 


					echo &#036;form-&gt;field(&#036;model1, 'visit')-&gt;dropDownList(


					[0=&gt; 'visit', 1=&gt; 'revisit'] ,[&quot;class&quot;=&gt;&quot;form-control&quot;,&quot;prompt&quot;=&gt;&quot;select&quot;]);


				?&gt;


			


			


			&lt;div class=&quot;form-group&quot;&gt;


					&lt;?= Html::submitButton(&#036;model1-&gt;isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' =&gt; &#036;model1-&gt;isNewRecord ? 'btn btn-default ' : 'btn btn-default','name'=&gt;'submits']) ?&gt;


			&lt;/div&gt;


	


	&lt;?php ActiveForm::end(); ?&gt;

</div>

issue is ur using one attribute ‘booking_date’ at both places thats why.

u can do by custom variable…

@model define variable

public $booking_datepat;

@appointment form

<?= $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”,

]

]);

?>

<?= $form->field($model1, ‘booking_datepat’)->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”,

]

]);

?>

Thank you so much.It works now

we should learn yii features deeply once… it helps a lot nd shorting our code too.

mark as ‘+’ dear.