Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » SimpleTreeDropdownField makes Problems

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 2529 Views
  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: SimpleTreeDropdownField makes Problems Link to this post

    Hi, i've run in the same problem. my goal is to show some images with a redirect link on homepage.

    my class:

    <?php
    class CustomImage extends DataObject
    {
       //db fields
       static $db = array (
    'Description' => 'Varchar(100)',
    );

       /**
        * Our custom image class contains one image that is used on one page.
        */
       public static $has_one = array (
          'SliderImage' => 'Image',
          'PageRedirect' => 'SiteTree'
       );

       /**
        * Popup for editing a single image.
        *
        * @return FieldSet The iframe for editing the image.
        */
       public function getCMSFields_forPopup(){
          $fields = new FieldSet(
             new TextField('Description'),
             new SimpleTreeDropDownField('PageRedirectID','Bild verlinkt zu','SiteTree'),
             new FileIFrameField('SliderImage','Bild für den Slider', Null, Null, Null, 'Uploads/homepage-sliderbilder/')
          );
          return $fields;
       }   
    }

    and my model:

    class HomePage extends Page {
    static $db = array(
          'HomeMainHeading' => 'Text',
          'HomeSubHeading' => 'Text',
          'HomeCol1' => 'HTMLText',
          'HomeCol2' => 'HTMLText'
    );

       public static $has_many = array(
       'CustomImages' => 'CustomImage',
       );

    function getCMSFields() {
          $fields = parent::getCMSFields();
          
          //SliderImages
          $images = new ImageDataObjectManager(
       $this, // Controller
       'CustomImages', // Source name
       'CustomImage', // Source class
       'SliderImage', // File name on DataObject
       array(
    'Description' => 'Description' //,
    // 'PageRedirect' => 'PageRedirect'
       ), // Headings
    'getCMSFields_forPopup' // Detail fields
    // Filter clause
    // Sort clause
    // Join clause
        );    
          ...   
          $fields->addFieldToTab('Root.Content.SliderBilder', $images);
          return $fields;
       }
    }

    if i comment out the PageRedirect in the array there is an error (…the method 'fortemplate' does not exist on…). otherwise the SimpleTreeDropDownField is not shown in the popup. Whats wrong with this code?

    Thanks for your help. Pipifix

  • Pipifix
    Avatar
    Community Member
    54 Posts

    Re: SimpleTreeDropdownField makes Problems Link to this post

    Hello.

    I'm still searching a solution for that. So i will appreciate your help. If i change the the PageRedirect in PageRedirectID in the ImageDataObjectManager the dropdown is also not shown. Maybe someone can give me a tip or point me to the error?

    Thanks Pipifix

    2529 Views
Page: 1 2
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.