Browse Source

Fixes #968: clientOptions should not be ignored when enabling internationalization.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
bc743a32b7
  1. 13
      extensions/jui/yii/jui/DatePicker.php

13
extensions/jui/yii/jui/DatePicker.php

@ -9,6 +9,7 @@ namespace yii\jui;
use Yii; use Yii;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Json;
/** /**
* DatePicker renders an datepicker jQuery UI widget. * DatePicker renders an datepicker jQuery UI widget.
@ -61,11 +62,19 @@ class DatePicker extends InputWidget
public function run() public function run()
{ {
echo $this->renderWidget() . "\n"; echo $this->renderWidget() . "\n";
$this->registerWidget('datepicker', DatePickerAsset::className());
if ($this->language !== false) { if ($this->language !== false) {
$view = $this->getView(); $view = $this->getView();
DatePickerRegionalAsset::register($view); DatePickerRegionalAsset::register($view);
$view->registerJs("$('#{$this->options['id']}').datepicker('option', $.datepicker.regional['{$this->language}']);"); // do not pass in any options when creating the widget
// set the options later so that the options can be combined with regional options
$options = $this->clientOptions;
$this->clientOptions = array();
$this->registerWidget('datepicker', DatePickerAsset::className());
$this->clientOptions = $options;
$options = Json::encode($options);
$view->registerJs("$('#{$this->options['id']}').datepicker('option', $.extend({}, $.datepicker.regional['{$this->language}'], $options));");
} else {
$this->registerWidget('datepicker', DatePickerAsset::className());
} }
} }

Loading…
Cancel
Save