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

10 March 2010 at 10:44pm Last edited: 10 March 2010 10:57pm
No, getting no error. It just won't store the value.
Never mind, looks like I don't need it anyway.
But thanks
-
Re: TreeDropdownField: unselect selected value

10 March 2010 at 11:09pm
And TreeDrowndownField stores the value?
The OptionalTreeDrowndownField extends the TreeDropdownField so I don't know why one would work and the other one doesn't. The only difference between the two I can think of is that if you do not select a value it tries to store a null value, but that should only be an issue if you don't select a value.
-
Re: TreeDropdownField: unselect selected value

10 March 2010 at 11:48pm
no, both of them didn't store the value.
But when I use this code:new TreeDropdownField("InternLinkID", "Velg hvor artikkelen skal linkes til", "SiteTree"
This stores the value.
-
Re: TreeDropdownField: unselect selected value

11 March 2010 at 12:00am
Then it should also work for:
new OptionalTreeDropdownField("InternLinkID", "Velg hvor artikkelen skal linkes til", "SiteTree"
-
Re: TreeDropdownField: unselect selected value

11 March 2010 at 12:31am
yes, it should.
But I don't need that function after all..
-
Re: TreeDropdownField: unselect selected value

11 March 2010 at 5:48am
Been a long time since I posted this one
Thanks, Marijn -
Re: TreeDropdownField: unselect selected value

17 June 2010 at 11:19pm
I´m trying to get the OptionalTreeDropDownField working under SS 2.4, as the code above doesn´t return any sitetree when using it under SS 2.4.
Obviuosly the method TreeDropdownField::gettree() has changed to TreeDropdownField::tree($request) in Version 2.4 (see doc: http://api.silverstripe.org/2.4/forms/fields-relational/TreeDropdownField.html#methodtree)
My first try was to just change the method name to tree() (without any param). But this results in an 'missing argument' error and doesn´t return anything.
So obviously you need to pass the parameter '$request' which is of the type 'SS_HTTPRequest'.
My problem: I don´t know how to generate a variable with the current SS_HTTPRequest.
Does anybody know how to correctly call the mehtod TreeDropdownField::tree($request), so that it returns the current Sitetree? -
Re: TreeDropdownField: unselect selected value

18 June 2010 at 2:59am Last edited: 18 June 2010 3:00am
Hi Silverseba,
I had noticed that it didn't work, but didn't see the urgency of fixing it yet, your post encouraged me to though
As the OptionalTreeDropdownField is an extension of TreeDropdownField we don't need to generate the SS_HTTPRequest $request variable. It is passed by the calling function to our function. Below the full updated code of the OptionalTreeDropdownField.
<?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 = '</ul>';/**
* Helper function to return the header (rather than defining same line twice).
*/
function preTree() {
return '<ul class="tree"><li id="" 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;
}
}
| 4391 Views | ||
| Go to Top | Next > |



