Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » TreeDropdownField not displaying anything on SilverStripe 3.0

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

Page: 1
Go to End
Author Topic: 567 Views
  • mrsteveheyes
    Avatar
    Community Member
    15 Posts

    TreeDropdownField not displaying anything on SilverStripe 3.0 Link to this post

    Hi there.

    I am wanting to do related pages on my site. How I did this on 2.4 was use a related SiteTree object and TreeDropdownField. The code I'm using is bellow:

    public static $has_one = array(

    'Feature1Page' => 'SiteTree',
    );

    public function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Main', new TreeDropdownField('Feature1PageID', 'Feature 1 Link', 'SiteTree'));

    $return $fields;
    }

    The dropdown menu shows in the CMS, but when I go to select something and press the arrow down button nothing is shown. Am I missing something or done something wrong? Or is this a bug that needs fixing in 3.0?

    Cheers,
    Steve

  • vegetav
    Avatar
    Community Member
    23 Posts

    Re: TreeDropdownField not displaying anything on SilverStripe 3.0 Link to this post

    That looks like it should work to me. I am doing using the TreeDropdownField in a DatObject in 3.0.1 in the same way thaty ou are and it works fine for me.

    Here is my code for reference...

    class Feature extends DataObject {
       static $db = array (
          'Title' => 'Text',
       );

       static $has_one = array (
    'HomePage' => 'HomePage',
    'LinkPage' => 'SiteTree',
       );

    public static $summary_fields = array(
    'Title' => 'Title',
    );

    public function getCMSFields() {
    return new FieldList(
    new TextField('Title'),
    new TreeDropdownField('LinkPageID', 'Link', 'SiteTree')
    );
    }
    }

    And in my template...

    <% loop Features %>
       <a href="$LinkPage.Link" id="link$ID">$Title</a>
    <% end_loop %>

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