Reputation: 21
I would like to customize a form helper template for just a plugin, not across the App.
Example: 'inputContainer' => '<div class="form-control">{{content}}</div>',
How do I go about doing this in CakePHP 3?
Upvotes: 0
Views: 170
Reputation: 1364
As per the docs - to change theme inline at runtime use setTemplate
:
$myTemplates = [
'inputContainer' => '<div class="form-control">{{content}}</div>',
];
?>
<?= $this->Form->create('Users') ?>
<? $this->Form->setTemplates($myTemplates); ?>
<?=
$this->Form->input('email', [
'class' => 'form-control',
'templates' => [
'formGroup' => '{{input}}{{label}}'
]])
?>
You can't use the templates
option on the Form for a dynamic template, it will only look for a config file listing template items in /config
.
Upvotes: 1