diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 9d7e3a916..971f5c9c7 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -512,7 +512,7 @@ class FormHelper extends AppHelper { unset($options[$error]); } - if ($text != null) { + if ($text !== null) { $error = $text; } elseif (is_numeric($error)) { $error = sprintf(__('Error in field %s', true), Inflector::humanize($this->field())); diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 4244c3be2..d2c945490 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1325,6 +1325,34 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * testEmptyErrorValidation method + * + * test validation error div + * + * @access public + * @return void + */ + function testEmptyErrorValidation() { + $this->Form->validationErrors['Contact']['password'] = 'Please provide a password'; + $result = $this->Form->input('Contact.password', array('error' => '')); + $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' => 'error-message')), + array(), + '/div', + '/div' + ); + $this->assertTags($result, $expected); + } + /** * testFormValidationAssociated method * @@ -5804,7 +5832,7 @@ class FormHelperTest extends CakeTestCase { $expected = array( 'form' => array( - 'id' => 'ContactAddForm', 'method' => 'post', + 'id' => 'ContactAddForm', 'method' => 'post', 'onsubmit' => 'someFunction();event.returnValue = false; return false;', 'action' => '/contacts/index/param', 'accept-charset' => 'utf-8'