Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

TreeDropdownField remove link


Go to End


3 Posts   1589 Views

Avatar
dh

Community Member, 13 Posts

18 December 2012 at 12:34am

hi,
i have a optional TreeDropdownField. how can i remove the link after setting?

Avatar
zenmonkey

Community Member, 545 Posts

8 January 2013 at 5:49pm

If this is SS3 you can call the create the field using teh ORM pattern as opposed to the old new TreeDropdownFIeld and then just chain on setEmptyString

so instead of something like

$fields->addFieldToTab("Root.Main", new TreeDropdownField("RelationID","Title","SiteTree"));

you could do
$fields->addFieldToTab("Root.Main", TreeDropdownField::create("RelationID","Title","SiteTree")->setEmptyString('(Select page)'));

Avatar
MarioSommereder

Community Member, 107 Posts

12 January 2013 at 5:46am

Hi. I'm looking also for an solution for that issue.

Your solution won't work because TreeDropdownField has no method setEmptyString() because its not a child of DropdownField.

In the forum I came across something like this http://www.silverstripe.org/form-questions/show/5733?start=16, but this wraps the whole tree inside the reset link. Works, but is not very nice.

Isn't there any easy solution? I wonder that this isn't build in by default :-(

Cheers, Mario