I installed the above extension via composer and follow the documentation for every step; in my :
view : use kartik\datecontrol\DateControl;// <?=$form->field($model, 'dated')->widget(DateControl::classname(), [
'type'=>DateControl::FORMAT_DATE,
'ajaxConversion'=>false,
'options' => ['pluginOptions' => ['autoclose' => true ],'class'=>'col-xs-12 form-control input-sm']])?>
Web.php - Module configuration :
use \kartik\datecontrol\Module;
'datecontrol' => [
'class' => 'kartik\datecontrol\Module',
// format settings for displaying each date attribute (ICU format example)
'displaySettings' => [
Module::FORMAT_DATE => 'php:dd-m-Y',
Module::FORMAT_TIME => 'php:H:i:s',
Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
],
// format settings for saving each date attribute (PHP format example)
'saveSettings' => [
Module::FORMAT_DATE => 'php:Y-m-d',
Module::FORMAT_TIME => 'php:H:i:s',
Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',
],
// set your display timezone
// 'displayTimezone' => 'Asia/Kolkata',
// set your timezone for date saved to db
// 'saveTimezone' => 'UTC',
// automatically use kartik\widgets for each of the above formats
'autoWidget' => true,
// default settings for each widget from kartik\widgets used when autoWidget is true
'autoWidgetSettings' => [
Module::FORMAT_DATE => ['type'=>2, 'pluginOptions'=>['autoclose'=>true]], // example
Module::FORMAT_DATETIME => [], // setup if needed
Module::FORMAT_TIME => [], // setup if needed
],
// custom widget settings that will be used to render the date input instead of kartik\widgets,
// this will be used when autoWidget is set to false at module or widget level.
'widgetSettings' => [
Module::FORMAT_DATE => [
'class' => 'yii\jui\DatePicker', // example
'options' => [
'dateFormat' => 'php:d-M-Y',
'options' => ['class'=>'form-control'],
]
]
]
// other settings
]
When I run the view I got the following error message :
{"name":"Invalid Configuration","message":"The class '\kartik\date\DatePicker' was not found and is required for DateControl 'date' format.\n\nPlease ensure you have installed one of 'yii2-widgets' OR 'yii2-widget-datepicker' extensions. To install, you can run this console command from your application root:\n\nphp composer.phar require kartik-v/yii2-widgets: \"@dev\"\n\n--- OR ---\n\nphp composer.phar require kartik-v/yii2-widget-datepicker: \"@dev\"","code":0,"type":"yii\base\InvalidConfigException","file":"C:\wamp\www\pub\vendor\kartik-v\yii2-krajee-base\Config.php","line":118,"stack-trace":["#0 C:\wamp\www\pub\vendor\kartik-v\yii2-krajee-base\Config.php(195): kartik\base\Config::checkDependency('\\kartik\\date\\Da...', Array, 'for DateControl...')","#1 C:\wamp\www\pub\vendor\kartik-v\yii2-datecontrol\DateControl.php(215): kartik\base\Config::validateInputWidget('\\kartik\\date\\Da...', 'for DateControl...')","#2 C:\wamp\www\pub\vendor\kartik-v\yii2-datecontrol\DateControl.php(154): kartik\datecontrol\DateControl->initConfig()","#3 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Object.php(107): kartik\datecontrol\DateControl->init()","#4 [internal function]: yii\base\Object->__construct(Array)","#5 C:\wamp\www\pub\vendor\yiisoft\yii2\di\Container.php(372): ReflectionClass->newInstanceArgs(Array)","#6 C:\wamp\www\pub\vendor\yiisoft\yii2\di\Container.php(151): yii\di\Container->build('kartik\\datecont...', Array, Array)","#7 C:\wamp\www\pub\vendor\yiisoft\yii2\BaseYii.php(344): yii\di\Container->get('kartik\\datecont...', Array, Array)","#8 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Widget.php(97): yii\BaseYii::createObject(Array)","#9 C:\wamp\www\pub\vendor\yiisoft\yii2\widgets\ActiveField.php(665): yii\base\Widget::widget(Array)","#10 C:\wamp\www\pub\views\activite\schedules.php(49): yii\widgets\ActiveField->widget('kartik\\datecont...', Array)","#11 C:\wamp\www\pub\vendor\yiisoft\yii2\base\View.php(325): require('C:\\wamp\\www\\pub...')","#12 C:\wamp\www\pub\vendor\yiisoft\yii2\base\View.php(247): yii\base\View->renderPhpFile('C:\\wamp\\www\\pub...', Array)","#13 C:\wamp\www\pub\vendor\yiisoft\yii2\base\View.php(149): yii\base\View->renderFile('C:\\wamp\\www\\pub...', Array, Object(app\controllers\ActiviteController))","#14 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Controller.php(371): yii\base\View->render('schedules', Array, Object(app\controllers\ActiviteController))","#15 C:\wamp\www\pub\controllers\ActiviteController.php(407): yii\base\Controller->render('schedules', Array)","#16 [internal function]: app\controllers\ActiviteController->actionAddsch('4')","#17 C:\wamp\www\pub\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)","#18 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array)","#19 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('addsch', Array)","#20 C:\wamp\www\pub\vendor\yiisoft\yii2\web\Application.php(84): yii\base\Module->runAction('activite/addsch', Array)","#21 C:\wamp\www\pub\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))","#22 C:\wamp\www\pub\web\index.php(12): yii\base\Application->run()","#23 {main}"]}
kartik\date\DatePicker
extension to use date control. – Insane Skullkartik-v/yii2-widgets
ORkartik-v/yii2-widget-datepicker
– Insane Skull