17 Yii::import(
'booster.widgets.TbBaseInputWidget');
45 $this->htmlOptions[
'type'] =
'text';
46 $this->htmlOptions[
'autocomplete'] =
'off';
48 if (!isset($this->options[
'language'])) {
49 $this->options[
'language'] = substr(Yii::app()->getLanguage(), 0, 2);
60 public function run() {
62 list($name, $id) = $this->resolveNameID();
64 if ($this->hasModel()) {
66 echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions);
68 echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions);
72 echo CHtml::textField($name, $this->
value, $this->htmlOptions);
77 $options = !empty($this->options) ? CJavaScript::encode($this->options) :
'';
80 echo
"jQuery('#{$id}').datepicker({$options})";
81 foreach ($this->events as $event => $handler) {
82 echo
".on('{$event}', " . CJavaScript::encode($handler) .
")";
85 Yii::app()->getClientScript()->registerScript(__CLASS__ .
'#' . $this->getId(), ob_get_clean() .
';');
107 if (isset($this->options[
'language']) && $this->options[
'language'] !=
'en') {
108 $filename =
'/bootstrap-datepicker/js/locales/bootstrap-datepicker.' . $this->options[
'language'] .
'.js';
110 if (file_exists(Yii::getPathOfAlias(
'booster.assets') . $filename)) {
111 if ($booster->enableCdn) {
112 Yii::app()->clientScript->registerScriptFile(
113 '//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.2.0/js/locales/bootstrap-datepicker.' . $this->options[
'language'] .
'.js',
114 CClientScript::POS_HEAD
117 $booster->cs->registerScriptFile($booster->getAssetsUrl() . $filename, CClientScript::POS_HEAD);