Passing empty string in [\'error\'] behaved like false, now will behave like any other string

This commit is contained in:
Ceeram 2011-09-28 11:02:17 +02:00 committed by Ber Clausen
parent d489d490a6
commit 9f23f65755
2 changed files with 30 additions and 2 deletions

View file

@ -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()));

View file

@ -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'