I want to use yii2 datepicker but I'm having trouble to implement this. It does not show the date picker and I don't know what is missing in my code. I'm still new in this yii
<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
?>
<div class="row">
<div class="col-lg-6">
<div class="myproj-index">
<?php $form = ActiveForm::begin(['layout' => 'horizontal']); ?>
<? //$form->field($model, 'periodfrom')
echo DatePicker::widget([
'model' => $model,
'attribute' => 'periodfrom',
'language' => 'en',
'dateFormat' => 'yyyy-MM-dd',
]);
?>
<div class="form-group">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>
Edit
I downloaded this file here jui
I found out that in my file I have no jui folder under yiisoft folder. My question in appasset how can I declare this files ?
Answer
I fixed it, I downloaded the jquery-ui files then added them to the bower folder in yii2.
First install this extension through composer.
php composer.phar require --prefer-dist yiisoft/yii2-jui "*"
in your project directory.use yii\jui\DatePicker;
.You probably did not install Datepicker in the vendor package. Thanks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With