mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Changes reverted. Added 2 tests of error-related options
This commit is contained in:
parent
5ba9e41df8
commit
08d11154a7
2 changed files with 57 additions and 1 deletions
|
@ -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<br>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<br>otherwise you will not be able to login',
|
||||
'/div',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test validation errors, when validation message is an empty string.
|
||||
*
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue