Permalink
Browse files

ENHANCEMENT: Make GridFieldAddNewButton Content more specific

* Alter Grid Field "Add New" Button to take the name of the table (i.e.
"Add Member")
* Alter table names in security section to be singular so the button
text makes sense
  • Loading branch information...
1 parent 1747298 commit 16982ba17c222390084f657c200901aa0aa01af4 @adrexia adrexia committed May 21, 2012
@@ -68,7 +68,7 @@ public function getEditForm($id = null, $fields = null) {
if($record && !$record->canView()) return Security::permissionFailure($this);
$memberList = GridField::create(
- 'Members',
+ 'Member',
false,
DataList::create('Member'),
$memberListConfig = GridFieldConfig_RecordEditor::create()
@@ -77,7 +77,7 @@ public function getEditForm($id = null, $fields = null) {
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator(new Member_Validator());
$groupList = GridField::create(
- 'Groups',
+ 'Group',
false,
DataList::create('Group'),
GridFieldConfig_RecordEditor::create()
@@ -129,7 +129,7 @@ public function getEditForm($id = null, $fields = null) {
// Add roles editing interface
if(Permission::check('APPLY_ROLES')) {
- $rolesField = GridField::create('Roles',
+ $rolesField = GridField::create('Role',
false,
DataList::create('PermissionRole'),
GridFieldConfig_RecordEditor::create()
@@ -57,6 +57,8 @@ class GridField extends FormField {
*/
protected $columnDispatch = null;
+ protected $name = '';
+
/**
* Creates a new GridField field
*
@@ -67,6 +69,7 @@ class GridField extends FormField {
*/
public function __construct($name, $title = null, SS_List $dataList = null, GridFieldConfig $config = null) {
parent::__construct($name, $title, null);
+ $this->name = $name;
if($dataList) {
$this->setList($dataList);
@@ -79,8 +82,7 @@ public function __construct($name, $title = null, SS_List $dataList = null, Grid
}
$this->config->addComponent(new GridState_Component());
- $this->state = new GridState($this);
-
+ $this->state = new GridState($this);
$this->addExtraClass('ss-gridfield');
}
@@ -15,6 +15,7 @@ public function __construct($targetFragment = 'before') {
public function getHTMLFragments($gridField) {
$data = new ArrayData(array(
'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
+ 'ButtonName' => _t('GridField.Add', 'Add') . ' ' . _t('GridField.' . $gridField -> name, $gridField -> name),
));
return array(
$this->targetFragment => $data->renderWith('GridFieldAddNewbutton'),
@@ -1 +1,3 @@
-<a href="$NewLink" class="action action-detail ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all new new-link" data-icon="add"><% _t('GridField.AddNew', 'Add New') %></a>
+<a href="$NewLink" class="action action-detail ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all new new-link" data-icon="add">
+$ButtonName
+</a>

0 comments on commit 16982ba

Please sign in to comment.