如何在 yii2 basic 中使用日期选择器? [英] How to use datepicker in yii2 basic?

查看:36
本文介绍了如何在 yii2 basic 中使用日期选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 yii2 datepicker,但我无法实现它.它不显示日期选择器,我不知道我的代码中缺少什么.我还是这个 yii 的新手

<div class="row"><div class="col-lg-6"><div class="myproj-index"><?php $form = ActiveForm::begin(['layout' =>'horizo​​ntal']);?><?//$form->field($model, 'periodfrom')echo DatePicker::widget(['模型' =>$模型,'属性' =>'期间从','语言' =>'恩','日期格式' =>'yyyy-MM-dd',]);?><div class="form-group"><?= Html::submitButton('Submit', ['class' =>'btn btn-primary']) ?>

<?php ActiveForm::end();?>

编辑

我在这里下载了这个文件jui

我发现在我的文件中我的 yiisoft 文件夹下没有 jui 文件夹.我在 appasset 中的问题如何声明这些文件?

回答

我修复了它,我下载了 jquery-ui 文件,然后将它们添加到 yii2 的 bower 文件夹中.

解决方案

首先通过 composer 安装此扩展.

  1. 运行:php composer.phar require --prefer-dist yiisoft/yii2-jui "*" 在你的项目目录中.
  2. 更新作曲家.
  3. 在你的视图文件中使用 use yii\jui\DatePicker;.

您可能没有在供应商软件包中安装 Datepicker.谢谢.

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.

  1. run: php composer.phar require --prefer-dist yiisoft/yii2-jui "*" in your project directory.
  2. update composer.
  3. In your view file use use yii\jui\DatePicker;.

You probably did not install Datepicker in the vendor package. Thanks.

这篇关于如何在 yii2 basic 中使用日期选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆