mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Allow querystrings in arguments passed to Controller::join_links()
Fix FormField::Link() to allow querystrings in the form's action git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@61064 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
23d6fb8952
commit
292140897a
@ -458,16 +458,24 @@ class Controller extends RequestHandlingData {
|
|||||||
/**
|
/**
|
||||||
* Joins two link segments together, putting a slash between them if necessary.
|
* Joins two link segments together, putting a slash between them if necessary.
|
||||||
* Use this for building the results of Link() methods.
|
* 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() {
|
static function join_links() {
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
$result = "";
|
||||||
$result = array_shift($args);
|
$querystrings = array();
|
||||||
foreach($args as $arg) {
|
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;
|
else $result .= $arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($querystrings) $result .= '?' . implode('&', $querystrings);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ class FormField extends RequestHandlingData {
|
|||||||
* Return a Link to this field
|
* Return a Link to this field
|
||||||
*/
|
*/
|
||||||
function Link() {
|
function Link() {
|
||||||
return $this->form->FormAction() . '/field/' . $this->name;
|
return Controller::join_links($this->form->FormAction(), 'field/' . $this->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user