Adding patch and test for ticket #2369

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4881 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
dho 2007-04-25 07:28:20 +00:00
parent 0d69e3a085
commit c529d363a8
2 changed files with 9 additions and 2 deletions

View file

@ -507,8 +507,10 @@ class HtmlHelper extends AppHelper {
$out = array();
foreach($options as $optValue => $optTitle) {
$optionsHere = array('value' => $optValue);
$optValue == $value ? $optionsHere['checked'] = 'checked' : null;
$optionsHere = array('value' => $optValue);
if ($value !== false && $optValue == $value) {
$optionsHere['checked'] = 'checked';
}
$parsedOptions = $this->_parseAttributes(array_merge($htmlAttributes, $optionsHere), null, '', ' ');
$individualTagName = $this->field() . "_{$optValue}";
$out[] = sprintf($this->tags['radio'], $this->model(), $this->field(), $individualTagName, $parsedOptions, $optTitle);

View file

@ -53,6 +53,11 @@ class HtmlHelperTest extends UnitTestCase {
$this->assertPattern($expected, $result);
}
function testRadio() {
$result = $this->Html->radio('Tests/process', Array('0'=> 'zero', '1'=>'one'));
$this->assertNoPattern('/checked="checked"/', $result);
}
function tearDown() {
unset($this->Html);