diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 17dd064c5..449f05b3b 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1041,6 +1041,7 @@ class FormHelper extends AppHelper { public function radio($fieldName, $options = array(), $attributes = array()) { $attributes = $this->_initInputField($fieldName, $attributes); $legend = false; + $disabled = array(); if (isset($attributes['legend'])) { $legend = $attributes['legend']; @@ -1066,6 +1067,11 @@ class FormHelper extends AppHelper { } else { $value = $this->value($fieldName); } + + if (isset($attributes['disabled'])) { + $disabled = $attributes['disabled']; + } + $out = array(); $hiddenField = isset($attributes['hiddenField']) ? $attributes['hiddenField'] : true; @@ -1077,6 +1083,9 @@ class FormHelper extends AppHelper { if (isset($value) && $optValue == $value) { $optionsHere['checked'] = 'checked'; } + if (!empty($disabled) && in_array($optValue, $disabled)) { + $optionsHere['disabled'] = true; + } $tagName = Inflector::camelize( $attributes['id'] . '_' . Inflector::slug($optValue) ); diff --git a/lib/Cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php index 5476f837a..ce5150e8b 100644 --- a/lib/Cake/tests/cases/libs/cache.test.php +++ b/lib/Cake/tests/cases/libs/cache.test.php @@ -307,7 +307,7 @@ class CacheTest extends CakeTestCase { 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) ), true); - Cache::config('test_trigger', array('engine' => 'TestAppCache')); + Cache::config('test_trigger', array('engine' => 'TestAppCache', 'prefix' => '')); try { Cache::write('fail', 'value', 'test_trigger'); $this->fail('No exception thrown'); diff --git a/lib/Cake/tests/cases/libs/view/helpers/form.test.php b/lib/Cake/tests/cases/libs/view/helpers/form.test.php index 51e09d85d..9764c70ff 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/form.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/form.test.php @@ -3018,6 +3018,35 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test disabled radio options + * + * @return void + */ + function testRadioDisabled() { + $result = $this->Form->radio( + 'Model.field', + array('option A', 'option B'), + array('disabled' => array('option A'), 'value' => 'option A') + ); + $expected = array( + 'fieldset' => array(), + 'legend' => array(), + 'Field', + '/legend', + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField0', 'disabled' => 'disabled', 'checked' => 'checked')), + array('label' => array('for' => 'ModelField0')), + 'option A', + '/label', + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField1')), + array('label' => array('for' => 'ModelField1')), + 'option B', + '/label', + '/fieldset' + ); + $this->assertTags($result, $expected); + } + /** * test disabling the hidden input for radio buttons * diff --git a/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php b/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php index 1a8a47ac0..86b7688fb 100644 --- a/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php +++ b/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php @@ -19,7 +19,7 @@ class TestAppCacheEngine extends CacheEngine { public function write($key, $value, $duration) { - if ($key = 'fail') { + if ($key == 'fail') { return false; } }