diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index 0409d46d9..f75eca7a2 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -749,6 +749,11 @@ class AjaxHelper extends AppHelper { foreach ($options as $k => $v) { if (in_array($k, $acceptable)) { + if ($v === true) { + $v = 'true'; + } elseif ($v === false) { + $v = 'false'; + } $out[] = "$k:$v"; } } @@ -817,7 +822,7 @@ class AjaxHelper extends AppHelper { */ function _optionsToString($options, $stringOpts = array()) { foreach ($stringOpts as $option) { - if (isset($options[$option]) && !$options[$option][0] != "'") { + if (isset($options[$option]) && $options[$option][0] != "'") { if ($options[$option] === true || $options[$option] === 'true') { $options[$option] = 'true'; } elseif ($options[$option] === false || $options[$option] === 'false') { diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php index ee10e82c7..f240ed71a 100644 --- a/cake/tests/cases/libs/view/helpers/ajax.test.php +++ b/cake/tests/cases/libs/view/helpers/ajax.test.php @@ -48,10 +48,10 @@ if (!class_exists('Post')) { class Post extends Model { - + var $primaryKey = 'id'; var $useTable = false; - + function loadInfo() { return new Set(array( array('name' => 'id', 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), @@ -94,7 +94,7 @@ class AjaxTest extends UnitTestCase { function testAutoComplete() { $result = $this->Ajax->autoComplete('Post/title' , '/posts', array('minChars' => 2)); - + $this->assertPattern('/^]+name="data\[Post\]\[title\]"[^<>]+autocomplete="off"[^<>]+\/>/', $result); $this->assertPattern('/]+id="PostTitle_autoComplete"[^<>]*><\/div>/', $result); $this->assertPattern('/]+class="auto_complete"[^<>]*><\/div>/', $result); @@ -125,6 +125,16 @@ class AjaxTest extends UnitTestCase { $this->assertEqual($result, $expected); } + function testSortable() { + $result = $this->Ajax->sortable('ull', array('constraint'=>false,'ghosting'=>true)); + $expected = ''; + $this->assertEqual($result, $expected); + + $result = $this->Ajax->sortable('ull', array('constraint'=>'false','ghosting'=>'true')); + $expected = ''; + $this->assertEqual($result, $expected); + } + function testSubmitWithIndicator() { $result = $this->Ajax->submit('Add', array('div' => false, 'url' => "/controller/action", 'indicator' => 'loading', 'loading' => "doSomething()", 'complete' => 'doSomethingElse() ')); $this->assertPattern('/onLoading:function\(request\) {doSomething\(\);\s+Element.show\(\'loading\'\);}/', $result);