mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API CHANGE: Created GridFieldAddNewButton, replacing the one that was previously hardcoded in GridFieldToolbarHeader
This commit is contained in:
parent
12618e2027
commit
818c341c57
24
forms/gridfield/GridFieldAddNewButton.php
Normal file
24
forms/gridfield/GridFieldAddNewButton.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* This component provides a button for opening the add new form provided by {@link GridFieldDetailForm}.
|
||||
*
|
||||
* @package sapphire
|
||||
* @subpackage gridfield
|
||||
*/
|
||||
class GridFieldAddNewButton implements GridField_HTMLProvider {
|
||||
protected $targetFragment;
|
||||
|
||||
public function __construct($targetFragment = 'before') {
|
||||
$this->targetFragment = $targetFragment;
|
||||
}
|
||||
|
||||
public function getHTMLFragments($gridField) {
|
||||
$data = new ArrayData(array(
|
||||
'NewLink' => Controller::join_links($gridField->Link('item'), 'new'),
|
||||
));
|
||||
return array(
|
||||
$this->targetFragment => $data->renderWith('GridFieldAddNewbutton'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
1
templates/Includes/GridFieldAddNewButton.ss
Normal file
1
templates/Includes/GridFieldAddNewButton.ss
Normal file
@ -0,0 +1 @@
|
||||
<a href="$NewLink" class="action 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>
|
Loading…
x
Reference in New Issue
Block a user