Closed WaterSpout closed 10 years ago
I do not understand Russian, but I am trying to understand from the context, what you are saying. There is a reason why $this->pluginOptions['value']
must be set to null
. If you do not pass a value, the slider will display a wrong initial value - it will display the half point value (e.g. the slider will display 5
when no value is set and when the max
is set to 10
).
Also, in GridView setting a filter input value to null - should display all values by default. It is what you want anyway. What is the error you are facing?
i'm sorry, for wrong language. I wanted to say, when i try pass a value in pluginOptions
slider-range does not work, $this->pluginOptions['value']
always = null since $this->value
always = null
You should not pass the value in pluginOptions
. Instead you should set the value of the source attribute. For example, in your case:
// set a default value or change the condition below to
// what you need (you can change the $model->search()
// function as well to achieve this).
if (empty($model->payment)) {
$model->payment = [5,99];
}
// render gridview
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $model,
'columns' => [
[
'attribute'=>'payment',
'filterType'=>GridView::FILTER_SLIDER,
'filterWidgetOptions'=>[
'pluginOptions'=>[
'min'=>1,
'max'=>1000,
'range'=>true
],
]
]
]
]);
sorry, hmm, right, but if i try do it, i get this error Array to string conversion
public static function input($type, $name = null, $value = null, $options = [])
{
$options['type'] = $type;
$options['name'] = $name;
$options['value'] = $value === null ? null : (string) $value; // <-- here
return static::tag('input', '', $options);
}
Will check and update on this. Meanwhile, you can also pass the value as a string concatenated by ,
...
e.g. 5,99
will work instead of passing it as an array. In fact will record this as a bug fix and update.
Thanks for your help
Extension is upgraded to release v1.1.0.Closed with the latest commit, for range you need to pass the two values together as a string separated with a ,
(comma). The value is also saved this way by the plugin.
Refer updated documentation and demos.
Wait for 30 minutes and update via composer.
Здравствуйте. При использование слайдера в GridView некорректно заносится предустановленное значение — value для range:
Для моего случая помогло комментирование 55-ой строки в yii2-slider / slider / Slider.php
$this->value — это свойство является пустым, а во всех случаях оно заполняется только после инициализации слайдера, следовательно свойство pluginOptions['value'] перезаписывается на null