diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 40a147782..43c1e68d1 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -2084,6 +2084,62 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * Test validation errors with error options + * + * @return void + */ + public function testPasswordValidationWithOptions() { + $Contact = ClassRegistry::getObject('Contact'); + $Contact->validationErrors['password'] = array('Please provide a password'); + + $result = $this->Form->input('Contact.password',array( + 'error' => array( + 'attributes' => array('class' => 'special-error-class'), + ) + )); + $expected = array( + 'div' => array('class' => 'input password error'), + 'label' => array('for' => 'ContactPassword'), + 'Password', + '/label', + 'input' => array( + 'type' => 'password', 'name' => 'data[Contact][password]', + 'id' => 'ContactPassword', 'class' => 'form-error' + ), + array('div' => array('class' => 'special-error-class')), + 'Please provide a password', + '/div', + '/div' + ); + $this->assertTags($result, $expected); + + $Contact->validationErrors['password'] = array('Please provide a password
otherwise you will not be able to login'); + $result = $this->Form->input('Contact.password',array( + 'error' => array( + 'attributes' => array( + 'class' => 'special-error-class', + 'escape' => false, + ) + ) + )); + $expected = array( + 'div' => array('class' => 'input password error'), + 'label' => array('for' => 'ContactPassword'), + 'Password', + '/label', + 'input' => array( + 'type' => 'password', 'name' => 'data[Contact][password]', + 'id' => 'ContactPassword', 'class' => 'form-error' + ), + array('div' => array('class' => 'special-error-class')), + 'Please provide a password
otherwise you will not be able to login', + '/div', + '/div' + ); + $this->assertTags($result, $expected); + } + /** * Test validation errors, when validation message is an empty string. * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index db1aa4164..83eb67eaf 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1095,7 +1095,7 @@ class FormHelper extends AppHelper { $out['error'] = null; if ($type !== 'hidden' && $error !== false) { - $errMsg = $this->error($fieldName, null, $error); + $errMsg = $this->error($fieldName, $error); if ($errMsg) { $divOptions = $this->addClass($divOptions, Hash::get($divOptions, 'errorClass', 'error')); if ($errorMessage) {