API CHANGE: Created GridFieldAddNewButton, replacing the one that was previously hardcoded in GridFieldToolbarHeader

This commit is contained in:
Sam Minnee 2012-03-09 16:50:43 +13:00
parent 12618e2027
commit 818c341c57
2 changed files with 25 additions and 0 deletions

View 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'),
);
}
}

View 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>