yiiwheels.widgets.datetimepicker.WhDateTimePicker language

参考 https://github.com/2amigos/yiiwheels/blob/master/widgets/datetimepicker/WhDateTimePicker.php

public function registerClientScript()
{
/* publish assets dir */
$path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
$assetsUrl = $this->getAssetsUrl($path);
 
/* @var $cs CClientScript */
$cs = Yii::app()->getClientScript();
 
$cs->registerCssFile($assetsUrl . '/css/bootstrap-datetimepicker.min.css');
$cs->registerScriptFile($assetsUrl . '/js/bootstrap-datetimepicker.min.js', CClientScript::POS_END);
if (isset($this->pluginOptions['language'])) {
$cs->registerScriptFile(
$assetsUrl . '/js/locales/bootstrap-datetimepicker.' . $this->pluginOptions['language'] . '.js'
, CClientScript::POS_END);
}
/* initialize plugin */
/* initialize plugin */
$selector = null === $this->selector
? '#' . TbArray::getValue('id', $this->htmlOptions, $this->getId()) . '_datetimepicker'
: $this->selector;
 
$this->getApi()->registerPlugin('datetimepicker', $selector, $this->pluginOptions);
 
if($this->events)
{
 
$this->getApi()->registerEvents($selector, $this->events);
}
}

 

如果本地的文件里没有红色标记的这句代码(CClientScript::POS_END)的话,请记得加上,再使用下面的方式即可

 

<?php $this->widget(
                    'yiiwheels.widgets.datetimepicker.WhDateTimePicker',
                    array(
                          'name' => 'UserModel[expire_date]',
                          'value' => $model->expire_date,
                          'id' => 'expire_date',
                          'pluginOptions' => array(
                              'format' => 'yyyy-MM-dd hh:mm:ss',
                              'language' => 'zh-CN'
                                                  ),
                         )
                   );
                ?>

  

posted @ 2014-05-24 17:02  Debm.Zhang  阅读(353)  评论(0编辑  收藏  举报