Remove DIV from fields in CAKEPHP version 3.x


#1

Please,
how can I remove DIV from fields and put my owner DIV?

Ex.

Email
Email

MY FORM

<?php echo $this->Form->create(); echo $this->Form->controls( [ 'name' => ['label' => 'Nome'], 'email' => ['label' => 'Email'] ], ['legend' => 'Update your post'] ); echo $this->Form->control('title', ['required' => false]); echo $this->Form->end(); ?>

Note: I tried ‘email’ => [‘label’ => ‘Email’,‘div’=>false], but did not work!!!

Thanks


#2

form templates (change for all inputs template):
https://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses

example in config/app_form_template_horizontal.php:

return [
    'inputContainer' => '<div class="form-group">{{content}}</div>',
    'inputContainerError' => '<div class="form-group has-error">{{content}}</div>',
    'label' => '<label class="control-label" {{attrs}}>{{text}}</label>',
    'input' => '<input type="{{type}}" name="{{name}}" {{attrs}} />',
    'textarea' => '<textarea name="{{name}}" {{attrs}}>{{value}}</textarea>',
    'select' => '<select name="{{name}}" {{attrs}}>{{content}}</select>'
];

In view:
$this->loadHelper('Form', ['templates' => 'app_form_template_horizontal']);

or if you want change only 1 input in form:

$form_template = ['input' => '<input type="{{type}}" name="{{name}}" {{attrs}} ></input><span class="help-block">Help text</span>'];
echo $this->Form->input('name', ['templates' => $form_template, 'class' => 'form-control', 'type' => 'text', 'label' => ['text' => 'Name']]);