1779 Posts in 582 Topics by 556 members
| Go to End | ||
| Author | Topic: | 4371 Views |
-
Re: TreeDropdownField: unselect selected value

18 June 2010 at 3:08am
Thank you Marijn for your fast response! Works like a charm!
And a very smooth backward compatibility for SS 2.3 as well. -
Re: TreeDropdownField: unselect selected value

8 March 2011 at 7:40am
I just adjusted your code a little bit for the 2.4.4 version. Now it is possible trigger all childknodes.
Hope it works for you.
<?php
/**
* TreeDropdown-like field that gives you a tree of items including an empty field, using ajax.
* Author: Marijn Kampf www.exadium.com
* Date: 24 Nov 2009
* Version: 2.0
* Revision date: 17 June 2010
* Changes: Updated to work with SilverStripe 2.4, tree function added.
*/
class OptionalTreeDropdownField extends TreeDropdownField {
private static $postTree = '</li></ul>';/**
* Helper function to return the header (rather than defining same line twice).
*/
function preTree() {
return '<li id="0" class="l"> <a>' . _t('OptionalTreeDropdownField.NONE', "(None)", PR_MEDIUM, 'Non selected value of a dropdown') . '</a>';
}/**
* Return the site tree
* For version 2.3 and earlier
*/
/*function gettree() {
echo $this->preTree();
parent::gettree();
echo $this->postTree;
}*//**
* Get the whole tree of a part of the tree via an AJAX request with empty / none item prepended.
*
* @param SS_HTTPRequest $request
* @return string
* for version 2.4 and later
*/
function tree($request) {
return $this->preTree() . parent::tree($request) . $this->postTree;
}
}
?> -
Re: TreeDropdownField: unselect selected value

9 November 2011 at 11:04am
Hi guys.
That was exactly what I was looking for! Thank you so much!
But there is a little bug in SS 2.4.5.
Everything is working as expected, as long as you select pages within the root level. If you open a subtree and try to select pages within it the pages are not selectable (Even the yellow hover highlighting is not working).Any suggestions?
-
Re: TreeDropdownField: unselect selected value

5 March 2012 at 11:35am
hi,
use DOM's SimpleTreeDropdownField:
$f = new SimpleTreeDropdownField("PageLinkToID","Page link to", "SiteTree");
$f->setHasEmptyDefault(true);regards
pali
-
Re: TreeDropdownField: unselect selected value

30 July 2012 at 12:36pm
Thanks Pali - Very nice simple solution!
| 4371 Views | ||
| Go to Top |




