mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #13054 from savedario/2.x
FormHelper does not respect passed 'escape' option for errors
This commit is contained in:
commit
3d216935c9
1 changed files with 56 additions and 0 deletions
|
@ -2084,6 +2084,62 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$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.
|
* Test validation errors, when validation message is an empty string.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue