当前位置: 移动技术网 > IT编程>开发语言>PHP > Yii2框架引用bootstrap中日期插件yii2-date-picker的方法

Yii2框架引用bootstrap中日期插件yii2-date-picker的方法

2018年02月27日  | 移动技术网IT编程  | 我要评论

9877海贼王,越狱第五季第七集,邓丽欣个人资料

本文实例讲述了yii2框架引用bootstrap中日期插件yii2-date-picker的方法。分享给大家供大家参考,具体如下:

最近在学习yii2 框架,发现框架很强大,而且结合了时下许多新的技术在里面。

简单记录一下yii2-date-picker插件的使用方法:

首先先了解一下github中的相关资源:https://github.com/2amigos/yii2-date-picker-widget

其次:在自己的项目中利用上面链接中的相关方法下载此资源,命令为:

php composer.phar require "2amigos/yii2-date-picker-widget" "*"

最后,在视图文件中使用下面的代码:

use dosamigos\datepicker\datepicker;

例子中提供了两种方法:

方法1. 使用widget方式

<?= datepicker::widget([
  'model' => $model,
  'attribute' => 'date',
  'template' => '{addon}{input}',
    'clientoptions' => [
      'autoclose' => true,
      'format' => 'dd-m-yyyy'
    ]
]);?>

方法2. activeform方式

<?= $form->field($model, 'date')->widget(
  datepicker::classname(), [
    // inline too, not bad
    'inline' => true,
    // modify template for custom rendering
    'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>',
    'clientoptions' => [
      'autoclose' => true,
      'format' => 'dd-m-yyyy'
    ]
]);?>

希望本文所述对大家基于yii框架的php程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网