/** * Registers CKEditor JS */ protected function registerClientScript() { $view = $this->getView(); DateTimePickerAsset::register($view); /* * Language fix * @author <https://github.com/sim2github> */ if (!isset($this->clientOptions['locale'])) { $appLanguage = strtolower(substr(Yii::$app->language, 0, 2)); //First 2 letters $this->clientOptions['locale'] = $appLanguage; } if (!$this->jsFormat) { $this->jsFormat = static::convertPhpDateToMomentJs(FormatConverter::convertDateIcuToPhp($this->phpFormat)); } if (!isset($this->clientOptions['format'])) { $this->clientOptions['format'] = $this->jsFormat; } if (!isset($this->clientOptions['minDate'])) { $this->clientOptions['minDate'] = '1900-01-01'; } if (!isset($this->clientOptions['widgetPositioning'])) { $this->clientOptions['widgetPositioning'] = ['horizontal' => $this->addonBefore ? 'left' : 'right', 'vertical' => 'auto']; } $config = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); $js[] = "\$('" . $this->selector . "').datetimepicker({$config})"; foreach ($this->clientEvents as $key => $value) { $js[] = ".on('{$key}', {$value})"; } $js[] = ";\n"; $view->registerJs(implode('', $js)); }
/** * Registers CKEditor JS */ protected function registerClientScript() { $view = $this->getView(); DateTimePickerAsset::register($view); if (!$this->jsFormat) { $this->jsFormat = DateTimePicker::convertPhpDateToMomentJs(FormatConverter::convertDateIcuToPhp($this->phpFormat)); } /* * locale fix * @author <https://github.com/sim2github> */ if (!isset($this->clientOptions['locale'])) { $applocale = strtolower(substr(Yii::$app->language, 0, 2)); //First 2 letters $this->clientOptions['locale'] = $applocale; } if (!isset($this->clientOptions['format'])) { $this->clientOptions['format'] = $this->jsFormat; } if (!isset($this->clientOptions2['locale'])) { $applocale = strtolower(substr(Yii::$app->language, 0, 2)); //First 2 letters $this->clientOptions2['locale'] = $applocale; } if (!isset($this->clientOptions2['format'])) { $this->clientOptions2['format'] = $this->jsFormat; } $config = empty($this->clientOptions) ? '' : Json::encode($this->clientOptions); $config2 = empty($this->clientOptions2) ? '' : Json::encode($this->clientOptions2); $js = "\$('#" . $this->options['id'] . "').datetimepicker({$config});"; $js .= "\$('#" . $this->options2['id'] . "').datetimepicker({$config2});"; $view->registerJs($js); }