BUGFIX: Fixed pagination in TableListField after hsmith's changes

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63819 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-10-08 03:32:33 +00:00
parent 332da65edb
commit 51447b89ab
2 changed files with 34 additions and 2 deletions

View File

@ -262,10 +262,10 @@ class TableListField extends FormField {
function index() { function index() {
return $this->FieldHolder(); return $this->FieldHolder();
} }
static $url_handlers = array( static $url_handlers = array(
'item/$ID' => 'handleItem', 'item/$ID' => 'handleItem',
'$Action!' => '$Action', '$Action' => '$Action',
); );
function sourceClass() { function sourceClass() {

View File

@ -94,6 +94,24 @@ class TableListFieldTest extends SapphireTest {
$this->assertEquals(array(3 => "a3", 4 => "a4"), $itemMap); $this->assertEquals(array(3 => "a3", 4 => "a4"), $itemMap);
} }
/**
* Get that visiting the field's URL returns the content of the field.
* This capability is used by ajax
*/
function testAjaxRefreshing() {
$controller = new TableListFieldTest_TestController();
$table = $controller->TestForm()->Fields()->First();
$ajaxResponse = Director::test($table->Link())->getBody();
// Check that the column headings have been rendered
$this->assertRegExp('/<th[^>]*>\s*Col A\s*<\/th>/', $ajaxResponse);
$this->assertRegExp('/<th[^>]*>\s*Col B\s*<\/th>/', $ajaxResponse);
$this->assertRegExp('/<th[^>]*>\s*Col C\s*<\/th>/', $ajaxResponse);
$this->assertRegExp('/<th[^>]*>\s*Col D\s*<\/th>/', $ajaxResponse);
$this->assertRegExp('/<th[^>]*>\s*Col E\s*<\/th>/', $ajaxResponse);
}
function testCsvExport() { function testCsvExport() {
$table = new TableListField("Tester", "TableListFieldTest_CsvExport", array( $table = new TableListField("Tester", "TableListFieldTest_CsvExport", array(
"A" => "Col A", "A" => "Col A",
@ -162,4 +180,18 @@ class TableListFieldTest_TestController extends Controller {
function Link() { function Link() {
return "TableListFieldTest_TestController/"; return "TableListFieldTest_TestController/";
} }
function TestForm() {
$table = new TableListField("Table", "TableListFieldTest_Obj", array(
"A" => "Col A",
"B" => "Col B",
"C" => "Col C",
"D" => "Col D",
"E" => "Col E",
));
// A TableListField must be inside a form for its links to be generated
return new Form($this, "TestForm", new FieldSet(
$table
), new FieldSet());
}
} }