diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php
index 00d112c3f..ca5d8248a 100644
--- a/cake/libs/view/helper.php
+++ b/cake/libs/view/helper.php
@@ -465,6 +465,13 @@ class Helper extends Overloadable {
}
}
+ if (is_array($options)) {
+ if (empty($result) && isset($options['default'])) {
+ $result = $options['default'];
+ }
+ unset($options['default']);
+ }
+
if (is_array($options)) {
$options[$key] = $result;
return $options;
diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php
index 6a83a1568..4c65e75e2 100644
--- a/cake/tests/cases/libs/view/helpers/form.test.php
+++ b/cake/tests/cases/libs/view/helpers/form.test.php
@@ -144,6 +144,16 @@ class FormHelperTest extends UnitTestCase {
$this->assertNoPattern('/]+[^type|name|id|value|class]=[^<>]*>/', $result);
}
+ function testDefaultValue() {
+ $this->Form->data['Model']['field'] = 'test';
+ $result = $this->Form->text('Model/field', array('default' => 'default value'));
+ $this->assertPattern('/^]+value="test"[^<>]+\/>$/', $result);
+
+ unset($this->Form->data['Model']['field']);
+ $result = $this->Form->text('Model/field', array('default' => 'default value'));
+ $this->assertPattern('/^]+value="default value"[^<>]+\/>$/', $result);
+ }
+
function testFieldError() {
$this->Form->validationErrors['Model']['field'] = 1;
$result = $this->Form->error('Model.field');