I have upgraded a site to SS3 from 2.4 and implemented a datagrid to replace an ImageDataObjectManager following this tutorial: http://www.inforbiro.com/blog-eng/silverstripe-gridfield-tutorial/
Everything is working fine, however I need it to open in a pop up in the cms as currently every time you upload a new image, you have to go back to the main page, then click on the image tab, then click Add image and then go through the process.
I tried adding (from http://www.silverstriperesources.com/articles/using-the-silverstripe-3-gridfield/):
$gridFieldConfig->addComponent($gridFieldForm = new GridFieldPopupForms());
$gridFieldForm->setTemplate('CMSGridFieldPopupForms');
But this is giving me an error: Class 'GridFieldPopupForms' not found.
I am using 3.0.0. The GridFieldPopupForms class does not exist in /sapphire/forms/gridfield/GridFieldPopupForms.php as the docs state.
My full code:
SliderImage.php
<?php
class SliderImage extends DataObject {
static $db = array (
'Title' => 'Varchar',
'ImageLink' => 'Varchar'
);
static $has_one = array (
'Home' => 'Home',
'SliderMainImage' => 'Image'
);
public static $summary_fields = array(
'Title' => 'Image Title',
'ImageLink' => 'Link for the image'
);
public function getCMSFields_forPopup() {
$imageField = new UploadField('SliderMainImage', 'Image');
$imageField->allowedExtensions = array('jpg', 'png', 'gif');
// Name, Description and Website fields
return new FieldList(
new TextField('Title', 'Title'),
new TextareaField('ImageLink', 'Link for the image'),
$thumbField
);
}
}
Home.php
public static $has_many = array(
'SliderImages' => 'SliderImage'
);
function getCMSFields() {
$fields = parent::getCMSFields();
$gridFieldConfig = GridFieldConfig::create()->addComponents(
new GridFieldToolbarHeader(),
new GridFieldAddNewButton('toolbar-header-right'),
new GridFieldSortableHeader(),
new GridFieldDataColumns(),
new GridFieldPaginator(10),
new GridFieldEditButton(),
new GridFieldDeleteAction(),
new GridFieldDetailForm()
);
$gridFieldConfig->addComponent($gridFieldForm = new GridFieldPopupForms());
$gridFieldForm->setTemplate('CMSGridFieldPopupForms');
$gridField = new GridField("SliderImages", "Slider Images:", $this->SliderImages(), $gridFieldConfig);
$fields->addFieldToTab("Root.Slider", $gridField);
return $fields;
}