我通过composer安装了上面的扩展程序,并按照每个步骤的文档进行操作;在我的:
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
]
当我运行视图时,我收到以下错误消息:
{“name”:“无效配置”,“消息”:“该课程 找不到'\ kartik \ date \ DatePicker'并且是必需的 DateControl'日期'格式。\ n \ n请确保您已安装其中一个 'yii2-widgets'OR'yii2-widget-datepicker'扩展。要安装,你 可以从应用程序root运行此控制台命令:\ n \ nphp composer.phar需要kartik-v / yii2-widgets:\“@ dev \”\ n \ n - 或者 - 或者 --- \ n \ n \ n \ nnphp composer.phar需要kartik -v / yii2-widget-datepicker:\“@ dev \”“,”code“:0,”type“:”yii \ base \ InvalidConfigException“,”file“ : “C:\瓦帕\ WWW \酒馆\厂商\卡尔蒂克-v \ yii2-krajee基\ config.php中”, “行”:118, “堆痕量”:[“#0 C:\瓦帕\ WWW \酒馆\厂商\卡尔蒂克-V \ yii2-krajee基\ config.php中(195): 卡尔蒂克\基地\配置:: checkDependency( '\\ \\卡尔蒂克日期\\大......', 数组,'for DateControl ...')“,”#1 C:\瓦帕\ WWW \酒馆\厂商\卡尔蒂克-V \ yii2-datecontrol \ DateControl.php(215): 卡尔蒂克\基地\配置:: validateInputWidget( '\\ \\卡尔蒂克日期\\大......', 'for DateControl ...')“,”#2 C:\瓦帕\ WWW \酒馆\厂商\卡尔蒂克-V \ yii2-datecontrol \ DateControl.php(154): 卡尔蒂克\ datecontrol \ DateControl-&GT; initConfig() “” #3 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ Object.php(107): kartik \ datecontrol \ DateControl-&gt; init()“,”#4 [内部函数]: YII \基\对象 - &GT; __构建体(阵列) “” #5 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \二\ Container.php(372): ReflectionClass-&GT; newInstanceArgs(阵列) “” #6 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \二\ Container.php(151): yii \ di \ Container-&gt; build('kartik \\ datecont ...',Array,Array)“,”#7 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \ BaseYii.php(344): yii \ di \ Container-&gt; get('kartik \\ datecont ...',Array,Array)“,”#8 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ Widget.php(97): YII \ BaseYii ::的CreateObject(阵列) “” #9 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \部件\ ActiveField.php(665): YII \基\的widget ::插件(阵列) “” #10 C:\瓦帕\ WWW \酒馆\视图\激活Google \ schedules.php(49): YII \部件\ ActiveField-&GT;插件( '卡尔蒂克\\ datecont ...', 阵列) “” #11 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ View.php(325): 需要( 'C:\\ \\ WAMP WWW \\的酒吧......') “” #12 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ View.php(247): YII \基\视图 - &GT; renderPhpFile( 'C:\\瓦帕\\ WWW \\酒馆...', 阵列) “” #13 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ View.php(149): yii \ base \ View-&gt; renderFile('C:\\ wamp \\ www \\ pub ...',Array, 对象(表观\控制器\ ActiviteController)) “” #14 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ Controller.php这样(371): yii \ base \ View-&gt; render('schedules',Array, 对象(表观\控制器\ ActiviteController)) “” #15 C:\瓦帕\ WWW \酒馆\控制器\ ActiviteController.php(407): yii \ base \ Controller-&gt; render('schedules',Array)“,”#16 [internal 功能]: 应用\控制器\ ActiviteController-&GT; actionAddsch( '4') “” #17 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ InlineAction.php(55): call_user_func_array(Array,Array)“,”#18 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ Controller.php这样(151): YII \基\ InlineAction-&GT; runWithParams(阵列) “” #19 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ Module.php(455): yii \ base \ Controller-&gt; runAction('addsch',Array)“,”#20 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \幅\ Application.php(84): yii \ base \ Module-&gt; runAction('activite / addsch',Array)“,”#21 C:\瓦帕\ WWW \酒馆\厂商\ yiisoft \ yii2 \碱\ Application.php(375): YII \网络\应用 - &GT;的handleRequest(对象(YII \网络\请求)) “” #22 C:\ WAMP \ WWW \酒吧\网络\的index.php(12): yii \ base \ Application-&gt; run()“,”#23 {main}“]}
答案 0 :(得分:3)
尝试安装以下小部件:
yii2-插件-日期选择器 yii2-插件-的DateTimePicker
或更好,使用composer安装kartik小部件:
php composer.phar require kartik-v/yii2-widgets "*"
将安装以下小部件: