我用过mootensai/yii2-enhanced-gii,他们说我应该在config\main.php
上添加这段代码:
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module',
// see settings on http://demos.krajee.com/grid#module
],
'datecontrol' => [
'class' => '\kartik\datecontrol\Module',
// see settings on http://demos.krajee.com/datecontrol#module
],
// If you use tree table
'treemanager' => [
'class' => '\kartik\tree\Module',
// see settings on http://demos.krajee.com/tree-manager#module
]
],
我正在使用Yii2 Basic,因此我将其添加到config/web.php
中,如下所示
'components' => [
// some code here !
],
'modules' => [
'gridview' => [
'class' => '\kartik\grid\Module',
],
'datecontrol' => [
'class' => '\kartik\datecontrol\Module',
],
'treemanager' => [
'class' => '\kartik\tree\Module',
]
],
因此,当我从Gii运行生成的代码时,它为我提供了日期归档的代码,如下所示:
<?= $form->field($model, 'regester_end_date')->widget(\kartik\datecontrol\DateControl::classname(), [
'type' => \kartik\datecontrol\DateControl::FORMAT_DATE,
'saveFormat' => 'php:Y-m-d',
'ajaxConversion' => true,
'options' => [
'pluginOptions' => [
'placeholder' => Yii::t('app', 'Choose Regester End Date'),
'autoclose' => true
]
],
]); ?>
运行表单时,它会给我一个问题,提示Class 'kartik\datecontrol\DateControl' not found
。我更新了作曲家,并安装了kartik小部件,没有任何反应
答案 0 :(得分:1)
kartik-v/yii2-datecontrol
既不是kartik-v/yii2-widgets
也不是mootensai/yii2-enhanced-gii
的一部分,则需要单独安装:
composer require kartik-v/yii2-datecontrol