Skip to content

Commit

Permalink
Move default buttons config to separate method for easy extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Sep 2, 2017
1 parent dbfbe22 commit d380085
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/Listener/Traits/FormTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,41 @@ protected function _getFormSubmitExtraButtons()
return [];
}

$defaults = [
[
if ($buttons === null || $buttons === true) {
$buttons = $this->_getDefaultExtraButtons();
}

return $buttons;
}

/**
* Get default extra buttons
*
* @return array
*/
protected function _getDefaultExtraButtons()
{
return [
'save_and_continue' => [
'title' => __d('crud', 'Save & continue editing'),
'options' => ['class' => 'btn btn-success btn-save-continue', 'name' => '_edit', 'value' => true],
'options' => ['class' => 'btn btn-success btn-save-continue', 'name' => '_edit', 'value' => '1'],
'type' => 'button',
'_label' => 'save_and_continue',
],
[
'save_and_create' => [
'title' => __d('crud', 'Save & create new'),
'options' => ['class' => 'btn btn-success', 'name' => '_add', 'value' => true],
'options' => ['class' => 'btn btn-success', 'name' => '_add', 'value' => '1'],
'type' => 'button',
'_label' => 'save_and_create',
],
[
'back' => [
'title' => __d('crud', 'Back'),
'url' => ['action' => 'index'],
'options' => ['class' => 'btn btn-default', 'role' => 'button', 'value' => true],
'options' => ['class' => 'btn btn-default', 'role' => 'button'],
'type' => 'link',
'_label' => 'back',
],
];

if ($buttons === null || $buttons === true) {
$buttons = $defaults;
}

return $buttons;
}

/**
Expand Down

0 comments on commit d380085

Please sign in to comment.