Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » TreeDropdownField in DataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1322 Views
  • IOTI
    Avatar
    Community Member
    189 Posts

    TreeDropdownField in DataObjectManager Link to this post

    Hello,

    I'm trying to get a TreeDropdownField in a DataObjectManager but can't seem to make it work. Here is my code
    HomPage.php

    //SideLinksDOM
          $SideLinksManager = new DataObjectManager(
             $this,
             'SideLinks',
             'SideLink',
             array(
                 'Label' => 'Label'
             ), 'getCMSFields_forPopup'
          );
          
          $SideLinksManager->setParentClass('HomePage');
          $fields->addFieldToTab('Root.Content.SideLinks', $SideLinksManager);
          
          return $fields;

    SideLink.php

    class SideLink extends DataObject{
       
       static $db = array(
          'Label' => 'Varchar(150)'
          
       );
       
       static $has_one = array(
          'Parent' => 'SiteTree',
          'Target' => 'SiteTree',
          'Image' => 'Image',
          'PageLink' => 'SiteTree'
          
       );
       
       public function getCMSFields(){
          
          $treeDropDownField = new TreeDropdownField("PageLinkID", "Choose a page to link to", "SiteTree");
          
          return new FieldSet(
             new TextField('Label', 'Label'),
             $treeDropDownField
          );
       }
    }

    The label field shows no problem but the drop down does not show up. If I change "PageLinkID" to "PageLink' it will show up but will not expand to show any fields.

    What am I doing wrong? thanks!

  • UncleCheese
    Avatar
    4085 Posts

    Re: TreeDropdownField in DataObjectManager Link to this post

    You need to use SimpleTreeDropdownField.

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • IOTI
    Avatar
    Community Member
    189 Posts

    Re: TreeDropdownField in DataObjectManager Link to this post

    great, thanks.

    And I see in the DataObjectManager docs SimpleTreeDropdownField is listed there. arg, when I get frustrated I forget to check the most obvious places.

    Thanks again.

    1322 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.