Skip to content
Permalink
Browse files

Allow string values for templates option.

This allows template files to be used with input(). This makes input()
consistent with create() and allows developers to use config files
better/more easily.

Refs #4015
  • Loading branch information...
markstory committed Jul 23, 2014
1 parent 65e633f commit ffc092bc39b566028d29d6da2e7d57b3cd190922
@@ -893,7 +893,8 @@ public function input($fieldName, array $options = []) {
if ($newTemplates) {
$templater->push();
$templater->add($options['templates']);
$templateMethod = is_string($options['templates']) ? 'load' : 'add';
$templater->{$templateMethod}($options['templates']);
}
unset($options['templates']);
@@ -2107,6 +2107,28 @@ public function testInputCustomization() {
$this->assertTags($result, $expected);
}
/**
* Test that input() accepts a template file.
*
* @return void
*/
public function testInputWithTemplateFile() {
$result = $this->Form->input('field', array(
'templates' => 'htmlhelper_tags'
));
$expected = array(
'label' => array('for' => 'field'),
'Field',
'/label',
'input' => array(
'type' => 'text', 'name' => 'field',
'id' => 'field'
),
);
$this->assertTags($result, $expected);
}
/**
* Test id prefix
*
@@ -3,5 +3,6 @@
$config = [
'formstart' => 'start form',
'formend' => 'finish form',
'hiddenblock' => '<div class="hidden">{{content}}</div>'
'hiddenblock' => '<div class="hidden">{{content}}</div>',
'inputContainer' => '{{content}}'
];

0 comments on commit ffc092b

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