BUGFIX #6299 TableListField::Link() includes $action value twice (thanks ajshort!) (from r115379)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@115380 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2011-01-10 03:46:28 +00:00
parent 2ed7c9c1b0
commit 60f237092a
2 changed files with 21 additions and 2 deletions

View File

@ -1197,7 +1197,7 @@ JS
$queryPart = (isset($parentUrlParts['query'])) ? '?' . $parentUrlParts['query'] : null;
// Ensure that URL actions not routed through Form->httpSubmission() are protected against CSRF attacks.
if($form->securityTokenEnabled()) $queryPart = $token->addtoUrl($queryPart);
return Controller::join_links($parentUrlParts['path'], $action, $queryPart);
return Controller::join_links($parentUrlParts['path'], $queryPart);
} else {
// allow for instanciation of this FormField outside of a controller/form
// context (e.g. for unit tests)

View File

@ -216,7 +216,26 @@ class TableListFieldTest extends SapphireTest {
unlink($csvFileName);
}
function testLink() {
// A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
new TableListField("Tester", "TableListFieldTest_Obj", array(
"A" => "Col A",
"B" => "Col B",
"C" => "Col C",
"D" => "Col D",
"E" => "Col E",
))
), new FieldSet());
$table = $form->dataFieldByName('Tester');
$this->assertEquals(
$table->Link('test'),
sprintf('TableListFieldTest_TestController/TestForm/field/Tester/test?SecurityID=%s', $form->dataFieldByName('SecurityID')->Value())
);
}
function testPreservedSortOptionsInPaginationLink() {
$item1 = $this->objFromFixture('TableListFieldTest_Obj', 'one');
$item2 = $this->objFromFixture('TableListFieldTest_Obj', 'two');