I can’t get DatePicker to work.
Code in view:
<?= $form->field($model, 'name')->widget( yii\jui\DatePicker::className(),['clientOptions' => ['dateFormat' => 'yy-mm-dd', 'defaultDate' => '2014-01-01']]) ?>
I get error:
Class ‘yii\jui\DatePicker’ not found
Result is the same.
Class DatePicker is located at vendor/yiisoft/yii2-jui/DatePicker.php
Where could be the problem?
Have you added on top of the file
in your code should be
yes, but it gives the same result
changed but it gives the same result
Did you install JUI Extension for Yii 2?
How to install: https://github.com/yiisoft/yii2-jui#installation
no, but I have already these files https://github.com/yiisoft/yii2-jui under /vendor/yiisoft/yii2-jui/
Is it possible you have a namespace problem? Make sure you have:
at the top of your DatePicker.php file.
How did you get /vendor/yiisoft/yii2-jui/? If you’ve just copied it it won’t work. You have to install it via Composer.
No? how did you install it? you can’t put the files by yourself! if you did that you need to modify the extension.php file. So i recommend you to install the extension by composer!!!
As Xview is saying, you should confirm that you have in extensions.php:
'name' => 'yiisoft/yii2-jui',
'version' => '126.96.36.199',
'@yii/jui' => $vendorDir . '/yiisoft/yii2-jui',
Otherwise it will not work. When you install an extension via composer, extensions.php is automatically updated for you, which is a lot easier in the long run than trying to keep track of it manually.