Skip to content

Commit

Permalink
Fix bug #947
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamsxin committed Jul 30, 2013
1 parent e1a9e5a commit c3166d9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
6 changes: 4 additions & 2 deletions ext/tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,10 @@ PHP_METHOD(Phalcon_Tag, _inputFieldChecked){

PHALCON_OBS_VAR(current_value);
phalcon_array_fetch_string(&current_value, params, SL("value"), PH_NOISY);
if (PHALCON_IS_EQUAL(current_value, value)) {
phalcon_array_update_string_string(&params, SL("checked"), SL("checked"), PH_SEPARATE);
if (Z_TYPE_P(value) != IS_NULL) {
if (PHALCON_IS_EQUAL(current_value, value)) {
phalcon_array_update_string_string(&params, SL("checked"), SL("checked"), PH_SEPARATE);
}
}
} else {
/**
Expand Down
32 changes: 31 additions & 1 deletion unit-tests/TagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,34 @@ public function testIssue744()
$this->assertTrue(true);
}
}
}

public function testIssue947()
{
use Phalcon\Tag;
$di = new Phalcon\DI\FactoryDefault();
Tag::setDI($di);

$html = Tag::radioField(array(
'test',
'value' => 1,
'checked' => 'checked'
));
$pos = strpos($html, 'checked="checked"');
$this->assertTrue($pos !== FALSE);

$html = Tag::radioField(array(
'test',
'value' => 0
));
$pos = strpos($html, 'checked="checked"');
$this->assertTrue($pos === FALSE);

Tag::setDefault("test", "0");
$html = Tag::radioField(array(
'test',
'value' => 0
));
$pos = strpos($html, 'checked="checked"');
$this->assertTrue($pos !== FALSE);
}
}

0 comments on commit c3166d9

Please sign in to comment.