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',