mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding test for form input templates
This commit is contained in:
parent
0ca5c11e6c
commit
b782563daf
3 changed files with 64 additions and 2 deletions
0
app/tmp/cache/persistent/empty
vendored
0
app/tmp/cache/persistent/empty
vendored
|
@ -883,7 +883,7 @@ class FormHelper extends AppHelper {
|
|||
break;
|
||||
case 'checkbox':
|
||||
$input = $this->checkbox($fieldName, $options);
|
||||
$format = $format ?: array('before', 'input', 'between', 'label', 'after', 'error');
|
||||
$format = $format ? $format : array('before', 'input', 'between', 'label', 'after', 'error');
|
||||
break;
|
||||
case 'radio':
|
||||
$input = $this->radio($fieldName, $radioOptions, $options);
|
||||
|
|
|
@ -6019,7 +6019,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/div',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected,true);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6041,5 +6041,67 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field city', '/div'));
|
||||
}
|
||||
|
||||
/**
|
||||
* tests the ability to change the order of the form input placeholder "input", "label", "before", "between", "after", "error"
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testInputTemplate() {
|
||||
$result = $this->Form->input('Contact.email', array(
|
||||
'type' => 'text', 'format' => array('input')
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
'input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][email]',
|
||||
'id' => 'ContactEmail'
|
||||
),
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.email', array(
|
||||
'type' => 'text', 'format' => array('input', 'label'),
|
||||
'label' => '<em>Email (required)</em>'
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
array('input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][email]',
|
||||
'id' => 'ContactEmail'
|
||||
)),
|
||||
'label' => array('for' => 'ContactEmail'),
|
||||
'em' => array(),
|
||||
'Email (required)',
|
||||
'/em',
|
||||
'/label',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->input('Contact.email', array(
|
||||
'type' => 'text', 'format' => array('input', 'between', 'label', 'after'),
|
||||
'between' => '<div>Something in the middle</div>',
|
||||
'after' => '<span>Some text at the end</span>'
|
||||
));
|
||||
$expected = array(
|
||||
'div' => array('class' => 'input text'),
|
||||
array('input' => array(
|
||||
'type' => 'text', 'name' => 'data[Contact][email]',
|
||||
'id' => 'ContactEmail'
|
||||
)),
|
||||
array('div' => array()),
|
||||
'Something in the middle',
|
||||
'/div',
|
||||
'label' => array('for' => 'ContactEmail'),
|
||||
'Email',
|
||||
'/label',
|
||||
'span' => array(),
|
||||
'Some text at the end',
|
||||
'/span',
|
||||
'/div'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue