mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Passing empty string in [\'error\'] behaved like false, now will behave like any other string
This commit is contained in:
parent
d489d490a6
commit
9f23f65755
2 changed files with 30 additions and 2 deletions
|
@ -512,7 +512,7 @@ class FormHelper extends AppHelper {
|
||||||
unset($options[$error]);
|
unset($options[$error]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($text != null) {
|
if ($text !== null) {
|
||||||
$error = $text;
|
$error = $text;
|
||||||
} elseif (is_numeric($error)) {
|
} elseif (is_numeric($error)) {
|
||||||
$error = sprintf(__('Error in field %s', true), Inflector::humanize($this->field()));
|
$error = sprintf(__('Error in field %s', true), Inflector::humanize($this->field()));
|
||||||
|
|
|
@ -1325,6 +1325,34 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$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
|
* testFormValidationAssociated method
|
||||||
*
|
*
|
||||||
|
@ -5804,7 +5832,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'form' => array(
|
'form' => array(
|
||||||
'id' => 'ContactAddForm', 'method' => 'post',
|
'id' => 'ContactAddForm', 'method' => 'post',
|
||||||
'onsubmit' => 'someFunction();event.returnValue = false; return false;',
|
'onsubmit' => 'someFunction();event.returnValue = false; return false;',
|
||||||
'action' => '/contacts/index/param',
|
'action' => '/contacts/index/param',
|
||||||
'accept-charset' => 'utf-8'
|
'accept-charset' => 'utf-8'
|
||||||
|
|
Loading…
Reference in a new issue