mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 09:06:02 +00:00
ENHANCEMENT Added has_many/many_many test cases for GridField
This commit is contained in:
parent
759f550434
commit
dd9f2a255d
@ -14,7 +14,8 @@ class Company extends DataObject {
|
||||
);
|
||||
|
||||
public static $has_one = array(
|
||||
'RelationFieldsTestPage' => 'RelationFieldsTestPage'
|
||||
'RelationFieldsTestPage' => 'RelationFieldsTestPage',
|
||||
'GridFieldTestPage' => 'GridFieldTestPage'
|
||||
);
|
||||
|
||||
public static $has_many = array(
|
||||
@ -22,7 +23,8 @@ class Company extends DataObject {
|
||||
);
|
||||
|
||||
static $belongs_many_many = array(
|
||||
'RelationFieldsTestPages' => 'RelationFieldsTestPage'
|
||||
'RelationFieldsTestPages' => 'RelationFieldsTestPage',
|
||||
'GridFieldTestPage' => 'GridFieldTestPage'
|
||||
);
|
||||
|
||||
public static $summary_fields = array('Name', 'Category', 'Revenue', 'CEO');
|
||||
|
@ -1,5 +1,17 @@
|
||||
<?php
|
||||
class GridFieldTestPage extends Page {
|
||||
|
||||
static $has_one = array(
|
||||
"HasOneCompany" => "Company",
|
||||
);
|
||||
|
||||
static $has_many = array(
|
||||
"HasManyCompanies" => "Company",
|
||||
);
|
||||
|
||||
static $many_many = array(
|
||||
"ManyManyCompanies" => "Company",
|
||||
);
|
||||
|
||||
public function requireDefaultRecords() {
|
||||
parent::requireDefaultRecords();
|
||||
@ -27,10 +39,30 @@ class GridFieldTestPage extends Page {
|
||||
$config->addComponent(new GridFieldAction_Delete());
|
||||
$config->addComponent(new GridFieldAction_Edit());
|
||||
$config->addComponent($forms = new GridFieldPopupForms());
|
||||
|
||||
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config);
|
||||
$fields->addFieldToTab('Root.NoRelation', $grid);
|
||||
|
||||
$fields->addFieldToTab('Root.GridField', $grid);
|
||||
$config = new GridFieldConfig();
|
||||
$config->addComponent(new GridFieldDefaultColumns());
|
||||
$config->addComponent(new GridFieldSortableHeader());
|
||||
$config->addComponent(new GridFieldPaginator);
|
||||
$config->addComponent(new GridFieldFilter());
|
||||
$config->addComponent(new GridFieldAction_Delete());
|
||||
$config->addComponent(new GridFieldAction_Edit());
|
||||
$config->addComponent(new GridFieldRelationAdd('Name'));
|
||||
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', new DataList('Company'),$config);
|
||||
$fields->addFieldToTab('Root.HasMany', $grid);
|
||||
|
||||
$config = new GridFieldConfig();
|
||||
$config->addComponent(new GridFieldDefaultColumns());
|
||||
$config->addComponent(new GridFieldSortableHeader());
|
||||
$config->addComponent(new GridFieldPaginator);
|
||||
$config->addComponent(new GridFieldFilter());
|
||||
$config->addComponent(new GridFieldAction_Delete());
|
||||
$config->addComponent(new GridFieldAction_Edit());
|
||||
$config->addComponent(new GridFieldRelationAdd('Name'));
|
||||
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', new DataList('Company'),$config);
|
||||
$fields->addFieldToTab('Root.ManyMany', $grid);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user