3
* CJuiDatePicker class file.
5
* @author Sebastian Thiere <sebathi@gmail.com>
6
* @link http://www.yiiframework.com/
7
* @copyright Copyright © 2008-2010 Yii Software LLC
8
* @license http://www.yiiframework.com/license/
11
Yii::import('zii.widgets.jui.CJuiInputWidget');
14
* CJuiDatePicker displays a datepicker.
16
* CJuiDatePicker encapsulates the {@link http://jqueryui.com/demos/datepicker/ JUI
19
* To use this widget, you may insert the following code in a view:
21
* $this->widget('zii.widgets.jui.CJuiDatePicker', array(
22
* 'name'=>'publishDate',
23
* // additional javascript options for the date picker plugin
27
* 'htmlOptions'=>array(
28
* 'style'=>'height:20px;'
33
* By configuring the {@link options} property, you may specify the options
34
* that need to be passed to the JUI datepicker plugin. Please refer to
35
* the {@link http://jqueryui.com/demos/datepicker/ JUI datepicker} documentation
36
* for possible options (name-value pairs).
38
* @author Sebastian Thierer <sebathi@gmail.com>
39
* @version $Id: CJuiDatePicker.php 99 2010-01-07 20:55:13Z qiang.xue $
40
* @package zii.widgets.jui
43
class CJuiDatePicker extends CJuiInputWidget
46
* @var string the locale ID (e.g. 'fr', 'de') for the language to be used by the date picker.
47
* If this property is not set, I18N will not be involved. That is, the date picker will show in English.
52
* @var string The i18n Jquery UI script file. It uses scriptUrl property as base url.
54
public $i18nScriptFile = 'jquery-ui-i18n.js';
58
* This method registers necessary javascript and renders the needed HTML code.
62
list($name,$id)=$this->resolveNameID();
64
if(isset($this->htmlOptions['id']))
65
$id=$this->htmlOptions['id'];
67
$this->htmlOptions['id']=$id;
68
if(isset($this->htmlOptions['name']))
69
$name=$this->htmlOptions['name'];
71
$this->htmlOptions['name']=$name;
74
echo CHtml::activeTextField($this->model,$this->attribute,$this->htmlOptions);
76
echo CHtml::textField($name,$this->value,$this->htmlOptions);
78
$options=CJavaScript::encode($this->options);
80
$js = "jQuery('#{$id}').datepicker($options);";
82
if (isset($this->language)){
83
$this->registerScriptFile($this->i18nScriptFile);
84
$js .= "\njQuery('#{$id}').datepicker('option', jQuery.datepicker.regional['{$this->language}']);";
87
Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id, $js);
b'\\ No newline at end of file'