From 75b7021c25195e1996591e5ff72b8536830514bb Mon Sep 17 00:00:00 2001 From: Mateusz Uzdowski Date: Wed, 3 Feb 2010 23:28:24 +0000 Subject: [PATCH] BUGFIX: reintroducing the forceValue url param, so the TreeDropdownField value can be set via JS (previously if the item was deep within the tree structure it would not be selected) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@98083 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/TreeDropdownField.php | 6 ++++-- javascript/TreeSelectorField.js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/forms/TreeDropdownField.php b/forms/TreeDropdownField.php index b4d2247d8..c5d260fdb 100755 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -183,8 +183,10 @@ class TreeDropdownField extends FormField { $obj->markPartialTree(); - if($forceValues = $this->value) { - if(($values = preg_split('/,\s*/', $forceValues)) && count($values)) foreach($values as $value) { + // allow to pass values to be selected within the ajax request + if( isset($_REQUEST['forceValue']) || $this->value ) { + $forceValue = ( isset($_REQUEST['forceValue']) ? $_REQUEST['forceValue'] : $this->value); + if(($values = preg_split('/,\s*/', $forceValue)) && count($values)) foreach($values as $value) { $obj->markToExpose($this->objectForKey($value)); } } diff --git a/javascript/TreeSelectorField.js b/javascript/TreeSelectorField.js index 623b566de..34ad925db 100755 --- a/javascript/TreeSelectorField.js +++ b/javascript/TreeSelectorField.js @@ -171,9 +171,10 @@ TreeDropdownField.prototype = { }, ajaxGetTree: function(after) { - var ajaxURL = this.helperURLBase() + 'tree/'; + var ajaxURL = this.helperURLBase() + 'tree?'; ajaxURL += $('SecurityID') ? '&SecurityID=' + $('SecurityID').value : ''; if($('Form_EditForm_Locale')) ajaxURL += "&locale=" + $('Form_EditForm_Locale').value; + if ( this.inputTag.value ) ajaxURL += '&forceValue=' + this.inputTag.value; if (this.search() != null) ajaxURL += "&search=" + this.search(); new Ajax.Request(ajaxURL, { method : 'get',