Permalink
Browse files

API CHANGE: Created GridFieldAddNewButton, replacing the one that was…

… previously hardcoded in GridFieldToolbarHeader
  • Loading branch information...
1 parent 12618e2 commit 818c341c57bc1f3a2e56764389e3a9be79c23bd8 @sminnee sminnee committed Mar 9, 2012
Showing with 25 additions and 0 deletions.
  1. +24 −0 forms/gridfield/GridFieldAddNewButton.php
  2. +1 −0 templates/Includes/GridFieldAddNewButton.ss
@@ -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'),
+ );
+ }
+
+}
@@ -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>

0 comments on commit 818c341

Please sign in to comment.