Skip to content

Commit 5841165

Browse files
committed
Fixing range option for prototype engine. Fixes #1509
1 parent f2a4b1e commit 5841165

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

cake/libs/view/helpers/prototype_engine.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,14 @@ function slider($options = array()) {
330330
unset($options['handle']);
331331

332332
if (isset($options['min']) && isset($options['max'])) {
333-
$options['range'] = array($options['min'], $options['max']);
333+
$options['range'] = sprintf('$R(%s,%s)', $options['min'], $options['max']);
334334
unset($options['min'], $options['max']);
335335
}
336-
$optionString = $this->_processOptions('slider', $options);
336+
$options = $this->_mapOptions('slider', $options);
337+
$options = $this->_prepareCallbacks('slider', $options);
338+
$optionString = $this->_parseOptions(
339+
$options, array_merge(array_keys($this->_callbackArguments['slider']), array('range'))
340+
);
337341
if (!empty($optionString)) {
338342
$optionString = ', {' . $optionString . '}';
339343
}

cake/tests/cases/libs/view/helpers/prototype_engine.test.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,11 @@ function testSlider() {
348348
'handle' => '#handle',
349349
'change' => 'change();',
350350
'complete' => 'complete();',
351-
'value' => 4
351+
'value' => 4,
352+
'min' => 10,
353+
'max' => 100
352354
));
353-
$expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, sliderValue:4});';
355+
$expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});';
354356
$this->assertEqual($result, $expected);
355357
}
356358

0 commit comments

Comments
 (0)