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) (from r98083)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102576 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-13 01:55:24 +00:00
parent a138531808
commit 5ba037cc04
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) {
if(!is_numeric($value)) continue;
$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',