diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 43ef30f8f9b..20e1f0335ad 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -700,7 +700,7 @@ function value($options = array(), $field = null, $key = 'value') { } if (is_array($options)) { - if (empty($result) && isset($options['default'])) { + if ($result === null && isset($options['default'])) { $result = $options['default']; } unset($options['default']); diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index d546a68773d..804f325c59c 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -385,6 +385,19 @@ function testValue() { $this->Helper->setEntity('HelperTestTag.HelperTestTag'); $result = $this->Helper->value('HelperTestTag.HelperTestTag'); $this->assertEqual($result, array(3 => 3, 5 => 5)); + + $this->Helper->data = array('zero' => 0); + $this->Helper->setEntity('zero'); + $result = $this->Helper->value(array('default' => 'something'), 'zero'); + $this->assertEqual($result, array('value' => 0)); + + $this->Helper->data = array('zero' => '0'); + $result = $this->Helper->value(array('default' => 'something'), 'zero'); + $this->assertEqual($result, array('value' => '0')); + + $this->Helper->setEntity('inexistent'); + $result = $this->Helper->value(array('default' => 'something'), 'inexistent'); + $this->assertEqual($result, array('value' => 'something')); } /**