diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php
index 0dcc1c140..1bbca6995 100644
--- a/cake/libs/view/helpers/form.php
+++ b/cake/libs/view/helpers/form.php
@@ -408,11 +408,10 @@ class FormHelper extends AppHelper {
if (is_array($text) && is_numeric($error) && $error > 0) {
$error--;
}
- if (is_array($text) && isset($text[$error])) {
- $text = $text[$error];
- } elseif (is_array($text)) {
+ if (is_array($text)) {
$options = array_merge($options, $text);
- $text = null;
+ $text = isset($text[$error]) ? $text[$error] : null;
+ unset($options[$error]);
}
if ($text != null) {
diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php
index af00110fd..5712d81e8 100644
--- a/cake/tests/cases/libs/view/helpers/form.test.php
+++ b/cake/tests/cases/libs/view/helpers/form.test.php
@@ -2235,14 +2235,14 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'data[Model][field]', 'value' => 'default value', 'id' => 'ModelField')));
}
/**
- * testFieldError method
+ * testError method
*
* Test field error generation
*
* @access public
* @return void
*/
- function testFieldError() {
+ function testError() {
$this->Form->validationErrors['Model']['field'] = 1;
$result = $this->Form->error('Model.field');
$this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field Field', '/div'));
@@ -2269,6 +2269,15 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->error('Model.field', "Badness!", array('wrap' => false, 'escape' => false));
$this->assertEqual($result, 'Badness!');
+
+ $this->Form->validationErrors['Model']['field'] = "email";
+ $result = $this->Form->error('Model.field', array('class' => 'field-error', 'email' => 'No good!'));
+ $expected = array(
+ 'div' => array('class' => 'field-error'),
+ 'No good!',
+ '/div'
+ );
+ $this->assertTags($result, $expected);
}
/**
* testPassword method