forked from unclecheese/silverstripe-gridfield-betterbuttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterButton_SaveAndNext.php
executable file
·55 lines (47 loc) · 1.28 KB
/
BetterButton_SaveAndNext.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace UncleCheese\BetterButtons\Buttons;
use UncleCheese\BetterButtons\Buttons\BetterButton;
/**
* Defines the button that saves a record and goes to the next one
*
* @author Uncle Cheese <unclecheese@leftandmain.com>
* @package silverstripe-gridfield-betterbuttons
*/
class BetterButton_SaveAndNext extends BetterButton
{
/**
* Builds the button
*/
public function __construct()
{
parent::__construct("doSaveAndNext", _t('GridFieldDetailForm.SAVEANDNEXT', 'Save and go to next record'));
}
/**
* Determines if the button should display
* @return boolean
*/
public function shouldDisplay()
{
$record = $this->gridFieldRequest->record;
return $record->canEdit();
}
/**
* Disables the button if there is no next record
* @return FormAction
*/
public function baseTransform()
{
parent::baseTransform();
$disabled = (!$this->gridFieldRequest->getNextRecordID());
return $this->setDisabled($disabled);
}
/**
* Adds a class that helps identify this button in a group
* @return FormAction
*/
public function transformToInput()
{
return parent::transformToInput()
->addExtraClass("saveAndGoNext");
}
}