Jump to:

23367 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » SS3: Open Data Grid in popup

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1512 Views
  • Fraser
    Avatar
    Community Member
    46 Posts

    SS3: Open Data Grid in popup Link to this post

    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;
       }

  • Thomashv
    Avatar
    Community Member
    32 Posts

    Re: SS3: Open Data Grid in popup Link to this post

    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.

  • Hattori
    Avatar
    Community Member
    20 Posts

    Re: SS3: Open Data Grid in popup Link to this post

    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

    1512 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.