From 7f2d888a40461dfa9808e2331863f73e638b01bd Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 25 May 2010 02:57:22 +0000 Subject: [PATCH] BUGFIX: tree selector base URL calculation wrong when field is nested (from r99739) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@105523 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/TreeSelectorField.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/javascript/TreeSelectorField.js b/javascript/TreeSelectorField.js index 5b3cac7d3..e7e21b97c 100755 --- a/javascript/TreeSelectorField.js +++ b/javascript/TreeSelectorField.js @@ -60,7 +60,14 @@ TreeDropdownField.prototype = { // Build a URL from the field's base URL and the given sub URL buildURL: function(subURL) { var baseURL = jQuery(this).attr('href'); - if (!baseURL) baseURL = this.ownerForm().action + '/field/' + this.getName() + '/'; + if (!baseURL) { + // Occurs if treedropdown has no form e.g. treefields in widget areas. + baseURL = this.ownerForm().action + '/field/' + this.getName() + '/'; + var baseTags = document.getElementsByTagName('base'); + var base = (baseTags) ? baseTags[0].href : ''; + if (base == baseURL.substring(0, base.length)) + baseURL = baseURL.substring(base.length); + } var subHasQuerystring = subURL.match(/\?/); if(baseURL.match(/^(.*)\?(.*)$/)) {