Skip to content

Commit

Permalink
fix: remove alternative methods of specifying extra submit buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Jun 28, 2017
1 parent 829a468 commit ed04357
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 82 deletions.
24 changes: 3 additions & 21 deletions docs/basic-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -356,36 +356,18 @@ Disabling the Extra Submit Buttons
----------------------------------

You may have noticed already that in the ``add`` form there are multiple submit
buttons. If you wish to only keep the "Save" button, you set the ``scaffold.disable_extra_buttons``
configuration key to ``true``:
buttons. If you wish to only keep the "Save" button, you set the
``scaffold.form_submit_extra_buttons`` configuration key to ``false``:

.. code-block:: php
public function add()
{
$action = $this->Crud->action();
$action->config('scaffold.disable_extra_buttons', true);
$action->config('scaffold.form_submit_extra_buttons', false);
return $this->Crud->execute();
}
It is also possible to only disable a few of the extra submit buttons by using
the ``scaffold.extra_buttons_blacklist`` configuration key:

.. code-block:: php
public function add()
{
$action = $this->Crud->action();
$action->config('scaffold.extra_buttons_blacklist', [
'save_and_continue', // Hide the Save and Continue button
'save_and_create', // Hide the Save and create new button
'back', // Hide the back button
]);
return $this->Crud->execute();
}
Both settings can be used in ``add`` and ``edit`` actions.

Implementing a View Action
--------------------------

Expand Down
61 changes: 0 additions & 61 deletions src/Listener/Traits/FormTypeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ protected function beforeRenderFormType()
$controller->set('formSubmitButtonText', $this->_getFormSubmitButtonText());
$controller->set('formSubmitExtraButtons', $this->_getFormSubmitExtraButtons());
$controller->set('formUrl', $this->_getFormUrl());
$controller->set('disableExtraButtons', $this->_getFormDisableExtraButtons());
$controller->set('extraButtonsBlacklist', $this->_getFormExtraButtonsBlacklist());
}

/**
Expand Down Expand Up @@ -53,16 +51,6 @@ protected function _getFormSubmitExtraButtons()
{
$action = $this->_action();

$disableExtraButtons = $this->_getFormDisableExtraButtons();
if ($disableExtraButtons === true) {
$this->deprecatedScaffoldKeyNotice(
'scaffold.disable_extra_buttons',
'scaffold.form_submit_extra_buttons'
);

return [];
}

$defaults = [
[
'title' => __d('crud', 'Save & continue editing'),
Expand All @@ -85,22 +73,6 @@ protected function _getFormSubmitExtraButtons()
],
];

$extraButtonsBlacklist = $this->_getFormExtraButtonsBlacklist();
if (!empty($extraButtonsBlacklist)) {
$this->deprecatedScaffoldKeyNotice(
'scaffold.extra_buttons_blacklist',
'scaffold.form_submit_extra_buttons'
);
$newDefaults = [];
foreach ($defaults as $default) {
if (in_array($default['_label'], $extraButtonsBlacklist)) {
continue;
}
$newDefaults[] = $default;
}
$defaults = $newDefaults;
}

$buttons = $action->getConfig('scaffold.form_submit_extra_buttons');
if ($buttons === null || $buttons === true) {
$buttons = $defaults;
Expand All @@ -113,32 +85,6 @@ protected function _getFormSubmitExtraButtons()
return $buttons;
}

/**
* Disable extra buttons.
*
* @return bool
* @deprecated 0.7.0 Deprecated in favor of form_submit_extra_buttons
*/
protected function _getFormDisableExtraButtons()
{
$action = $this->_action();

return $action->getConfig('scaffold.disable_extra_buttons') ?: false;
}

/**
* Get extra buttons blacklist
*
* @return array
* @deprecated 0.7.0 Deprecated in favor of form_submit_extra_buttons
*/
protected function _getFormExtraButtonsBlacklist()
{
$action = $this->_action();

return $action->getConfig('scaffold.extra_buttons_blacklist') ?: [];
}

/**
* Get form url.
*
Expand All @@ -160,11 +106,4 @@ abstract protected function _controller();
* {@inheritDoc}
*/
abstract protected function _action($name = null);

/**
* {@inheritDoc}
* @param string $deprecatedKey
* @param string $newKey
*/
abstract protected function deprecatedScaffoldKeyNotice($deprecatedKey, $newKey);
}

0 comments on commit ed04357

Please sign in to comment.