Alejandro Cabano
Alejandro Cabano

Reputation: 155

CakePHP 3.x with bootstrap form helper

Im upgrading from 2.x to 3.x version of CakePHP, I have a form that in 2.x was generated like this:

    <?php echo $this->Form->create('Articulo', array(
'class' => 'form-horizontal',
'inputDefaults' => array(
    'format' => array('before', 'label', 'between', 'input', 'error', 'after'),
    'div' => array('class' => 'control-group'),
    'label' => array('class' => 'control-label'),
    'between' => '<div class="controls">',
    'after' => '</div>',
    'error' => array('attributes' => array(
            'wrap' => 'span', 'class' => 'help-inline'
    )),
)));?>

but in 3.x version show this error:

Notice (8): Array to string conversion [CORE\src\View\StringTemplate.php, line 309]

I read in other posts that this kind of templates needs to be created in other file but nothing exactly what i'm looking for this situation.

Upvotes: 1

Views: 832

Answers (1)

Wile E. Genius
Wile E. Genius

Reputation: 185

In cakephp 3, the inputDefaults attribute has been removed. According to the docs (see Migration Guide) "you can use templates() to define/augment the templates FormHelper uses."

If you remove the inputDefaults-attribute, the warning will disappear.

Upvotes: 1

Related Questions