diff --git a/core/control/Controller.php b/core/control/Controller.php index 6c19c4ca3..5c35bdecb 100644 --- a/core/control/Controller.php +++ b/core/control/Controller.php @@ -458,16 +458,24 @@ class Controller extends RequestHandlingData { /** * Joins two link segments together, putting a slash between them if necessary. * Use this for building the results of Link() methods. + * + * If either of the links have query strings, then they will be combined and put at the end of the resulting url. */ static function join_links() { $args = func_get_args(); - - $result = array_shift($args); + $result = ""; + $querystrings = array(); foreach($args as $arg) { - if(substr($result,-1) != '/' && $arg[0] != '/') $result .= "/$arg"; + if(strpos($arg,'?') !== false) { + list($arg, $suffix) = explode('?',$arg,2); + $querystrings[] = $suffix; + } + if($result && substr($result,-1) != '/' && $arg[0] != '/') $result .= "/$arg"; else $result .= $arg; } + if($querystrings) $result .= '?' . implode('&', $querystrings); + return $result; } } diff --git a/forms/FormField.php b/forms/FormField.php index c74378dc2..cc0f4fb9f 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -74,7 +74,7 @@ class FormField extends RequestHandlingData { * Return a Link to this field */ function Link() { - return $this->form->FormAction() . '/field/' . $this->name; + return Controller::join_links($this->form->FormAction(), 'field/' . $this->name); } /**