PHP code example of guysartorelli / silverstripe-gridfield-preview
1. Go to this page and download the library: Download guysartorelli/silverstripe-gridfield-preview library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
guysartorelli / silverstripe-gridfield-preview example snippets
use GuySartorelli\GridFieldPreview\GridFieldPreviewButton;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordViewer;
//...
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Main', GridField::create(
'SomethingPreviewable',
'Something Previewable',
MyPreviewableDataObject::get(),
$config = GridFieldConfig_RecordViewer::create()
));
// Here's the important part - add the GridFieldPreviewButton component!
$config->addComponent(GridFieldPreviewButton::create());
return $fields;
}