forked from unclecheese/silverstripe-gridfield-betterbuttons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BetterButton_New.php
executable file
·48 lines (42 loc) · 1.26 KB
/
BetterButton_New.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
<?php
namespace UncleCheese\BetterButtons\Buttons;
use UncleCheese\BetterButtons\Buttons\BetterButton;
/**
* Defines the button that creates a new record
*
* @author Uncle Cheese <unclecheese@leftandmain.com>
* @package silverstripe-gridfield-betterbuttons
*/
class BetterButton_New extends BetterButton
{
/**
* Builds the button
* @param Form $form The form that holds the button
* @param GridFieldDetailForm_ItemRequest $request The request that points to the form
*/
public function __construct()
{
parent::__construct("doNew", _t('GridFieldBetterButtons.NEWRECORD', 'New record'));
}
/**
* Add the necessary classes and icons
* @return FormAction
*/
public function baseTransform()
{
parent::baseTransform();
return $this->addExtraClass("btn-primary font-icon-plus ss-ui-action-constructive");
}
/**
* Determines if the button should show
* @return boolean
*/
public function shouldDisplay()
{
// Do not show create new within create new
if ($this->gridFieldRequest->getRequest()->param('ID') == 'new') {
return false;
}
return $this->gridFieldRequest->record->canCreate();
}
}