For CakePHP 3.0 versions ...
... there is no way to just pass on attributes to a template. You'd have to redefine the appropriate form helper templates.
You can either change them globally by using for example FormHelper::templates()
:
$myTemplates = [
'inputContainer' => '<div class="col-md-4 input {{type}}{{required}}">{{content}}</div>',
'inputContainerError' => '<div class="col-md-4 input {{type}}{{required}} error">{{content}}{{error}}</div>'
];
$this->Form->templates($myTemplates);
or only for a specific input via the templates
option:
echo $this->Form->input('mobile', [
'templates' => [
'inputContainer' => '<div class="col-md-4 input {{type}}{{required}}">{{content}}</div>',
'inputContainerError' => '<div class="col-md-4 input {{type}}{{required}} error">{{content}}{{error}}</div>'
],
'class' => 'form-control',
'label' => false
]);
See also
As of CakePHP 3.1 ...
... you can use so called template variables. You can placed them anywhere in a template
$myTemplates = [
'inputContainer' => '<div class="input {{class}} {{type}}{{required}}">{{content}}</div>',
'inputContainerError' => '<div class="input {{class}} {{type}}{{required}} error">{{content}}{{error}}</div>'
];
$this->Form->templates($myTemplates);
and use the templateVars
option to define the values for them
echo $this->Form->input('mobile', [
'class' => 'form-control',
'label' => false,
'templateVars' => [
'class' => 'col-md-4'
]
]);
See also