Skip to content

Commit

Permalink
feat: add ability to set the default submit button text
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Dec 12, 2016
1 parent dca577a commit ca5115d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/Listener/ViewListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function beforeRender(Event $event)
$controller->set('bulkActions', $this->_getBulkActions());
$controller->set('viewblocks', $this->_getViewBlocks());
$controller->set('formUrl', $this->_getFormUrl());
$controller->set('submitButtonText', $this->_getSubmitButtonText());
$controller->set('disableExtraButtons', $this->_getDisableExtraButtons());
$controller->set('extraButtonsBlacklist', $this->_getExtraButtonsBlacklist());
$controller->set('enableDirtyCheck', $this->_getEnableDirtyCheck());
Expand Down Expand Up @@ -577,6 +578,18 @@ protected function _getFormUrl()
return $action->config('scaffold.form_action') ?: null;
}

/**
* Get submit button text.
*
* @return bool
*/
protected function _getSubmitButtonText()
{
$action = $this->_action();

return $action->config('scaffold.submit_button_text') ?: __d('crud', 'Save');
}

/**
* Disable extra buttons.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Element/form/buttons.ctp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="col pull-right">
<?php
echo $this->Form->button(__d('crud', 'Save'), ['class' => 'btn btn-primary', 'name' => '_save']);
echo $this->Form->button($submitButtonText, ['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]);
Expand Down

0 comments on commit ca5115d

Please sign in to comment.