Reputation: 163
My code is as below
<?php echo $form->field($model_emp_info, 'varDob')->textInput(['id'=>'datepicker'])?>
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
Upvotes: 1
Views: 1846
Reputation: 33538
No need to manually attach it like that.
Yii2 has official extension for jQuery UI which is available here.
Add it through composer and then you can use widgets for jQuery UI components.
Basic example with DatePicker (using with model):
echo DatePicker::widget([
'model' => $model,
'attribute' => 'from_date',
//'language' => 'ru',
//'dateFormat' => 'yyyy-MM-dd',
]);
You can read more in official docs.
Upvotes: 2