mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing custom error class not being used if error for field is a named index. Test case added. Fixes #76
This commit is contained in:
parent
c48d9794f6
commit
0065005f95
2 changed files with 14 additions and 6 deletions
|
@ -408,11 +408,10 @@ class FormHelper extends AppHelper {
|
|||
if (is_array($text) && is_numeric($error) && $error > 0) {
|
||||
$error--;
|
||||
}
|
||||
if (is_array($text) && isset($text[$error])) {
|
||||
$text = $text[$error];
|
||||
} elseif (is_array($text)) {
|
||||
if (is_array($text)) {
|
||||
$options = array_merge($options, $text);
|
||||
$text = null;
|
||||
$text = isset($text[$error]) ? $text[$error] : null;
|
||||
unset($options[$error]);
|
||||
}
|
||||
|
||||
if ($text != null) {
|
||||
|
|
|
@ -2235,14 +2235,14 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, array('input' => array('type' => 'text', 'name' => 'data[Model][field]', 'value' => 'default value', 'id' => 'ModelField')));
|
||||
}
|
||||
/**
|
||||
* testFieldError method
|
||||
* testError method
|
||||
*
|
||||
* Test field error generation
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testFieldError() {
|
||||
function testError() {
|
||||
$this->Form->validationErrors['Model']['field'] = 1;
|
||||
$result = $this->Form->error('Model.field');
|
||||
$this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field Field', '/div'));
|
||||
|
@ -2269,6 +2269,15 @@ class FormHelperTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Form->error('Model.field', "<strong>Badness!</strong>", array('wrap' => false, 'escape' => false));
|
||||
$this->assertEqual($result, '<strong>Badness!</strong>');
|
||||
|
||||
$this->Form->validationErrors['Model']['field'] = "email";
|
||||
$result = $this->Form->error('Model.field', array('class' => 'field-error', 'email' => 'No good!'));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'field-error'),
|
||||
'No good!',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testPassword method
|
||||
|
|
Loading…
Reference in a new issue