Source of file BetterButton_SaveAndClose.php
Size: 1,292 Bytes - Last Modified: 2021-12-23T10:56:01+00:00
/var/www/docs.ssmods.com/process/src/src/Buttons/BetterButton_SaveAndClose.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 | <?php namespace UncleCheese\BetterButtons\Buttons; use UncleCheese\BetterButtons\Buttons\BetterButton; /** * Defines the button that saves a record and closes the detail form * * @author Uncle Cheese <unclecheese@leftandmain.com> * @package silverstripe-gridfield-betterbuttons */ class BetterButton_SaveAndClose extends BetterButton { /** * Builds the button */ public function __construct() { parent::__construct("doSaveAndQuit", _t('GridFieldDetailForm.SAVEANDCLOSE', 'Save and close')); } /** * Determines if the button should show * @return boolean */ public function shouldDisplay() { $record = $this->gridFieldRequest->record; return $record->canEdit(); } /** * Adds a class that helps identify the button when in a group * @return FormAction */ public function transformToInput() { return parent::transformToInput() ->addExtraClass("saveAndClose"); } /** * Adds the correct style and icon * @return FormAction */ public function transformToButton() { return parent::transformToButton() ->addExtraClass('btn-primary font-icon-save') ->setAttribute('data-icon', 'accept'); } } |