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
This commit is contained in:
Mateusz Uzdowski 2010-02-03 23:28:24 +00:00 committed by Sam Minnee
parent eba7aa8fc0
commit 75b7021c25
2 changed files with 6 additions and 3 deletions

View File

@ -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));
}
}

View File

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