diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 9d7e3a916e4..971f5c9c73e 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -512,7 +512,7 @@ function error($field, $text = null, $options = array()) { 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 4244c3be28f..d2c9454905b 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 @@ function testPasswordValidation() { $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 @@ public function testCreateOnSubmit() { $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'