Skip to content

Commit 0216c9b

Browse files
author
Matthias Leutenegger
committed
prettify modeladmin
1 parent e4e65cc commit 0216c9b

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

lang/en.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
en:
2+
Syntro\SilverStripeSendy\Admin\SendyAdmin:
3+
MENUTITLE: Newsletter

src/Admin/SendyAdmin.php

+28-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<?php
22
namespace Syntro\SilverStripeSendy\Admin;
33

4+
use SilverStripe\Forms\FieldList;
5+
use SilverStripe\Forms\Form;
46
use SilverStripe\Admin\ModelAdmin;
7+
use SilverStripe\Forms\GridField\GridFieldExportButton;
8+
use SilverStripe\Forms\GridField\GridFieldImportButton;
9+
use SilverStripe\Forms\GridField\GridFieldPrintButton;
510
use Syntro\SilverStripeSendy\Model\SendyCampaign;
611

7-
812
/**
9-
* Description
13+
* Allows Users to manage campaigns
1014
*
11-
* @package silverstripe
12-
* @subpackage mysite
15+
* @author Matthias Leutenegger
1316
*/
1417
class SendyAdmin extends ModelAdmin
1518
{
@@ -39,5 +42,26 @@ class SendyAdmin extends ModelAdmin
3942
*/
4043
private static $menu_title = 'Newsletter';
4144

45+
/**
46+
* getEditForm - get the displayed edit form
47+
*
48+
* @param int $id = null the id of the record
49+
* @param FieldList $fields = null the fields
50+
* @return Form
51+
*/
52+
public function getEditForm($id = null, $fields = null)
53+
{
54+
$form = parent::getEditForm($id, $fields);
55+
if ($this->modelClass === SendyCampaign::class) {
56+
$listField = $form->Fields()->dataFieldByName($this->sanitiseClassName($this->modelClass));
57+
$config = $listField->getConfig();
58+
$config->removeComponentsByType([
59+
GridFieldExportButton::class,
60+
GridFieldImportButton::class,
61+
GridFieldPrintButton::class
62+
]);
63+
}
64+
return $form;
65+
}
4266

4367
}

0 commit comments

Comments
 (0)