Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7399879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:07:06+00:00 2026-05-29T04:07:06+00:00

I am using the TreeDropdownField for the SiteTree dropdown, although this is an optional

  • 0

I am using the TreeDropdownField for the SiteTree dropdown, although this is an optional field and would like to be able to clear/remove this value. How would I do this with Silverstripe?

    <?php 
class StaticSidebar extends Page {

    static $db = array(
        'ExternalLink' => 'Text',
        'ExternalText' => 'Varchar',
        'ImageLink' => 'Text'
    );

    static $has_one= array(
        "Image" => "Image",
        "InternalLink" => "SiteTree"
    );

    static $allowed_children = array("none");

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

    $fields->addFieldToTab("Root.Content.Main", new TextField("ExternalText", "External Text"), "Content");
    $fields->addFieldToTab("Root.Content.Main", new TextField("ExternalLink", "External Link"), "Content");
    $fields->addFieldToTab("Root.Content.Main", new TreeDropdownField("InternalLinkID", "Internal Link", "SiteTree"), "Content");
    $fields->addFieldToTab("Root.Content.Main", new ImageField("Image"), "Content");
    $fields->addFieldToTab("Root.Content.Main", new TextField("ImageLink", "Image Link"), "Content");

        return $fields;
    }       
} 

class StaticSidebar_Controller extends Page_Controller 
{


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:07:06+00:00Added an answer on May 29, 2026 at 4:07 am

    I’m afraid this isn’t possible with the TreeDropdownField.

    You could do something a little hacky like create a dummy page called “None” (with a specific page type e.g. NoPage) that a user can select and then you’d implement the onBeforeWrite method to check for this page type and then set the “InternalLinkID” field to 0 if the page selected is that page type. Not really that elegant though.

    The other option would be to use a DropdownField instead. This gives you a simple select box. Not as nice in terms of having a site tree view but you can set an “Empty” value.

    A third option might be to instead use the TreeMultiselectField. This field allows multiple selections (same as TreeDropdownField but uses checkboxes). At least this way you could deselect all items. The only issue would be which page to use if your CMS user selected more than one item.

    Edit: In SilverStripe 3 it is possible to clear/remove the TreeDropdownField selection by choosing the currently selected item.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Rails 3.2.0 with haml and sass: I Would like to link an external
Using Django, how do I generate the value of a field the first time
Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
using file_get_contents , I open an Internet URL and get the contents of this
using the jquery ui modal dialog , the background shades grey (i assuming this
Using Ivy with this Ant target: <target name=retrieve-jars> <ivy:retrieve pattern=WebContent/WEB-INF/lib/[artifact].[ext] /> </target> to fetch
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.