From a5866b73b7d789625da7e3dd119857001ef7c95f Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 20 Mar 2016 23:28:28 +0530 Subject: [PATCH] Move form buttons in a separate element so that they can be easily modified. --- src/Template/Element/form.ctp | 17 +---------------- src/Template/Element/form/buttons.ctp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 src/Template/Element/form/buttons.ctp diff --git a/src/Template/Element/form.ctp b/src/Template/Element/form.ctp index 4431aa50..4ffc9a13 100644 --- a/src/Template/Element/form.ctp +++ b/src/Template/Element/form.ctp @@ -19,22 +19,7 @@
-
- Form->button(__d('crud', 'Save'), ['class' => 'btn btn-primary', 'name' => '_save']); - if (empty($disableExtraButtons)) { - if (!in_array('save_and_continue', $extraButtonsBlacklist)) { - echo $this->Form->button(__d('crud', 'Save & continue editing'), ['class' => 'btn btn-success btn-save-continue', 'name' => '_edit', 'value' => true]); - } - if (!in_array('save_and_create', $extraButtonsBlacklist)) { - echo $this->Form->button(__d('crud', 'Save & create new'), ['class' => 'btn btn-success', 'name' => '_add', 'value' => true]); - } - if (!in_array('back', $extraButtonsBlacklist)) { - echo $this->Html->link(__d('crud', 'Back'), ['action' => 'index'], ['class' => 'btn btn-default', 'role' => 'button', 'value' => true]); - } - } - ?> -
+ element('form/buttons') ?>
diff --git a/src/Template/Element/form/buttons.ctp b/src/Template/Element/form/buttons.ctp new file mode 100644 index 00000000..3626192b --- /dev/null +++ b/src/Template/Element/form/buttons.ctp @@ -0,0 +1,16 @@ +
+ Form->button(__d('crud', 'Save'), ['class' => 'btn btn-primary', 'name' => '_save']); + if (empty($disableExtraButtons)) { + if (!in_array('save_and_continue', $extraButtonsBlacklist)) { + echo $this->Form->button(__d('crud', 'Save & continue editing'), ['class' => 'btn btn-success btn-save-continue', 'name' => '_edit', 'value' => true]); + } + if (!in_array('save_and_create', $extraButtonsBlacklist)) { + echo $this->Form->button(__d('crud', 'Save & create new'), ['class' => 'btn btn-success', 'name' => '_add', 'value' => true]); + } + if (!in_array('back', $extraButtonsBlacklist)) { + echo $this->Html->link(__d('crud', 'Back'), ['action' => 'index'], ['class' => 'btn btn-default', 'role' => 'button', 'value' => true]); + } + } + ?> +