Skip to content
Permalink
Browse files

Adding test for form input templates

  • Loading branch information...
lorenzo committed Feb 28, 2010
1 parent 0ca5c11 commit b782563daf50c6c9a26e580e592be3972f4583ff
No changes.
@@ -883,7 +883,7 @@ function input($fieldName, $options = array()) {
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 @@ function testMultiRecordForm() {
'/div',
'/div'
);
$this->assertTags($result, $expected,true);
$this->assertTags($result, $expected);
}
/**
@@ -6041,5 +6041,67 @@ function testMultiRecordFormValidationErrors() {
$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);
}
}
?>

0 comments on commit b782563

Please sign in to comment.
You can’t perform that action at this time.