forked from unclecheese/silverstripe-gridfield-betterbuttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterButton_Save.php
executable file
·44 lines (38 loc) · 986 Bytes
/
BetterButton_Save.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
<?php
namespace UncleCheese\BetterButtons\Buttons;
use UncleCheese\BetterButtons\Buttons\BetterButton;
/**
* Defines the button that saves a record
*
* @author Uncle Cheese <unclecheese@leftandmain.com>
* @package silverstripe-gridfield-betterbuttons
*/
class BetterButton_Save extends BetterButton
{
/**
* Builds the button
*/
public function __construct()
{
parent::__construct('save', _t('GridFieldDetailForm.SAVE', 'Save'));
}
/**
* Determines if the button should show
* @return boolean
*/
public function shouldDisplay()
{
$record = $this->gridFieldRequest->record;
return $record->canEdit();
}
/**
* Adds the appropriate icon and style
* @return FormAction
*/
public function transformToButton()
{
return parent::transformToButton()
->addExtraClass('btn-primary font-icon-save')
->setAttribute('data-icon', 'accept');
}
}