diff --git a/forms/gridfield/GridFieldPrintButton.php b/forms/gridfield/GridFieldPrintButton.php index d9623f68d..ea32a748f 100644 --- a/forms/gridfield/GridFieldPrintButton.php +++ b/forms/gridfield/GridFieldPrintButton.php @@ -131,10 +131,24 @@ class GridFieldPrintButton implements GridField_HTMLProvider, GridField_ActionPr )); $item->destroy(); } + + //get title for the print view + $form = $gridField->getForm(); + $currentController = Controller::curr(); + $title = method_exists($currentController, 'Title')?$currentController->Title(): + ($currentController->Title?$currentController->Title: + ($form?$form->Name():'')); + if($fieldTitle = $gridField->Title()) $title .= ($title?' - ':'').$fieldTitle; + + //$state = $gridField->getState(false)->__toString(); + $ret = new ArrayData( array( + "Title" => $title, "Header" => $header, "ItemRows" => $itemRows, + "Datetime" => SS_Datetime::now(), + "Member" => Member::currentUser(), ) ); diff --git a/templates/Includes/GridField_print.ss b/templates/Includes/GridField_print.ss index 149879472..ab832a0b4 100644 --- a/templates/Includes/GridField_print.ss +++ b/templates/Includes/GridField_print.ss @@ -1,8 +1,10 @@
+ + <% if $Title %>$CellString | <% end_control %>
+ Printed at $Datetime.Nice
+
+ Printed by $Member.Name
+