CakePHP Migration 2 to 3: Before / After Save Button Attribute (Helper Form Element)

Porting CakePHP 2.x to 3.x, in the submit button CakePHP 2.x has the after and before attribute, but it does not work with CakePHP 3.x.

<?php
 echo $this->Form->submit(__('Save'), array(
    'div' => 'form-actions',
    'class' => 'btn btn-large btn-primary btn-save',
    'data-loading-text' => 'Please Wait...',
    'after' => '    ' . $this->Html->link(__('Cancel'), array('admin' => true, 'action' => 'index'), array('class' => 'btn btn-large'))
)); ?>

Please help me how to get the button after the button in the submit button using CakePHP 3.x?

+4
source share
1 answer

When creating, submityou can use custom template. To use custom template, you need to use the FormHelper::inputc method 'type' => 'submit'instead of the method FormHelper::submit.

(submitContainer), ( form-actions, div CakePHP 3):

$after = $this->Html->link(__('Cancel'), 
    ['admin' => true, 'action' => 'index'], 
    ['class' => 'btn btn-large']
);
$this->Form->input (__('Save'), [
    'type'  => 'submit',
    'class' => 'btn btn-large btn-primary btn-save',
    'data-loading-text' => 'Please Wait...',
    'templates' => [
        'submitContainer' => '<div class="submit form-actions">{{content}}'.$after.'</div>'
    ]
]);

(, inputContainer), (CakePHP 3.1. 6) submitContainer ( , , FormHelper, , submit ).

+2

Source: https://habr.com/ru/post/1621382/


All Articles