andrew72ru/yii2-bootstrap-slider

Slider to choose a digit range

Installs: 5 094

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

Type:yii2-extension

1.0 2015-08-13 04:42 UTC

This package is auto-updated.

Last update: 2024-10-23 02:10:58 UTC


README

Slider to choose a number range. Based on seiyria/bootstrap-slider

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist andrew72ru/yii2-bootstrap-slider "*"

or add

"andrew72ru/yii2-bootstrap-slider": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

For more information, please visit seiyria/bootstrap-slider.

$form->field($model, 'property')
    ->widget(\andrew72ru\slider\Slider::className(), [
        'min'           => 100,     // Find min value form you model if you want
        'max'           => 1000,    // Find max value form you model if you want
        'value1'        => 150,     // Optional, value to first slider init. Refer to min if not set
        'value2'        => 350,     // Optional, value to second slider init. Refer to max if not set
        'step'          => 1,       // Optional, refer to 1 if not set,
        'options'       => [
            // Avaliable all seiyria/bootstrap-slider options
        ]
        'clientEvents'  => [
            'slide' => 'function(e) {console.log(e)}',
            'slideStart' => 'function(e) {console.log(e)}',
            'slideStop' => 'function(e) {console.log(e)}',
            'change' => 'function(e) {console.log(e)}',
            'slideEnabled' => 'function(e) {console.log(e)}',
            'slideDisabled' => 'function(e) {console.log(e)}',
        ]
    ])

Remember, slider send a 150,200 (comma separated) value to server. Tune you search model to split it or so.

For example

// Value – is a string value of form field 
if(strpos($value, ',') !== false)
    $where = ['between', 'value', explode(',', $value)[0], explode(',', $value)[1]];