21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 966 Views |
-
SS3: Open Data Grid in popup

18 July 2012 at 10:52am Last edited: 18 July 2012 11:52am
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;
} -
Re: SS3: Open Data Grid in popup

26 July 2012 at 9:54am
Hi Fraser,
Good question. Did you find a solution for this? I don't get this to work either. It would have been fine not having to go back everytime you ad a new row to the gridfield.
-
Re: SS3: Open Data Grid in popup

28 July 2012 at 6:47am
http://www.silverstriperesources.com/articles/using-the-silverstripe-3-gridfield/
Note: I'm currently working with an early pre release version of Silverstripe 3, and the code here is a start point and not everything works.
GridFieldPopupForms has been removed in the SS3 Stable release
| 966 Views | ||
|
Page:
1
|
Go to Top |



