diff --git a/extensions/yii/jui/SliderInput.php b/extensions/yii/jui/SliderInput.php index 8a43eb1..20599cf 100644 --- a/extensions/yii/jui/SliderInput.php +++ b/extensions/yii/jui/SliderInput.php @@ -15,7 +15,7 @@ use yii\helpers\Html; * For example, * * ``` - * echo Slider::widget([ + * echo SliderInput::widget([ * 'model' => $model, * 'attribute' => 'amount', * 'clientOptions' => [ @@ -28,7 +28,7 @@ use yii\helpers\Html; * The following example will use the name property instead: * * ``` - * echo Slider::widget([ + * echo SliderInput::widget([ * 'name' => 'amount', * 'clientOptions' => [ * 'min' => 1, @@ -75,8 +75,10 @@ class SliderInput extends InputWidget if ($this->hasModel()) { echo Html::activeHiddenInput($this->model, $this->attribute, $this->options); + $this->clientOptions['value'] = $this->model{$this->attribute}; } else { echo Html::hiddenInput($this->name, $this->value, $this->options); + $this->clientOptions['value'] = $this->value; } if (!isset($this->clientEvents['slide'])) { @@ -86,6 +88,5 @@ class SliderInput extends InputWidget } $this->registerWidget('slider', SliderAsset::className(), $this->containerOptions['id']); - $this->getView()->registerJs('$("#' . $this->options['id'] . '").val($("#' . $this->id . '").slider("value"));'); } } diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 287c5da..ba8eab2 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -16,6 +16,7 @@ Yii Framework 2 Change Log - Bug #1591: StringValidator is accessing undefined property (qiangxue) - Bug #1597: Added `enableAutoLogin` to basic and advanced application templates so "remember me" now works properly (samdark) - Bug #1631: Charset is now explicitly set to UTF-8 when serving JSON (samdark) +- Bug #1636: `yii\jui\SliderInput` wasn't properly initialized (samdark) - Bug #1686: ActiveForm is creating duplicated messages in error summary (qiangxue) - Bug: Fixed `Call to a member function registerAssetFiles() on a non-object` in case of wrong `sourcePath` for an asset bundle (samdark) - Bug: Fixed incorrect event name for `yii\jui\Spinner` (samdark)