2012-02-29 14:47:37 +01:00
|
|
|
<?php
|
2012-08-29 09:44:26 +02:00
|
|
|
class GridFieldTestPage extends TestPage {
|
2012-02-29 16:06:46 +01:00
|
|
|
|
|
|
|
static $has_one = array(
|
|
|
|
"HasOneCompany" => "Company",
|
|
|
|
);
|
|
|
|
|
|
|
|
static $has_many = array(
|
|
|
|
"HasManyCompanies" => "Company",
|
|
|
|
);
|
|
|
|
|
|
|
|
static $many_many = array(
|
|
|
|
"ManyManyCompanies" => "Company",
|
|
|
|
);
|
2012-02-29 14:47:37 +01:00
|
|
|
|
2012-04-13 15:59:19 +02:00
|
|
|
public function getCMSFields() {
|
2012-02-29 14:47:37 +01:00
|
|
|
$fields = parent::getCMSFields();
|
|
|
|
|
2012-03-09 06:24:18 +01:00
|
|
|
$config = new GridFieldConfig_RecordEditor();
|
2012-02-29 14:47:37 +01:00
|
|
|
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config);
|
2012-02-29 16:06:46 +01:00
|
|
|
$fields->addFieldToTab('Root.NoRelation', $grid);
|
2012-02-29 14:47:37 +01:00
|
|
|
|
2012-03-09 06:24:18 +01:00
|
|
|
$config = new GridFieldConfig_RelationEditor();
|
2012-08-29 09:44:26 +02:00
|
|
|
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(),$config);
|
2012-02-29 16:06:46 +01:00
|
|
|
$fields->addFieldToTab('Root.HasMany', $grid);
|
|
|
|
|
2012-03-09 06:24:18 +01:00
|
|
|
$config = new GridFieldConfig_RelationEditor();
|
2012-08-29 09:44:26 +02:00
|
|
|
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(),$config);
|
2012-02-29 16:06:46 +01:00
|
|
|
$fields->addFieldToTab('Root.ManyMany', $grid);
|
2012-02-29 14:47:37 +01:00
|
|
|
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class GridFieldTestPage_Controller extends Page_Controller {
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $Title = "GridFieldTestPage";
|
|
|
|
|
|
|
|
public function init(){
|
|
|
|
parent::init();
|
|
|
|
Requirements::css('frameworktest/css/gridfieldtest.css','screen');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return Form
|
|
|
|
*/
|
|
|
|
public function Form(){
|
2012-03-09 06:24:18 +01:00
|
|
|
$config = new GridFieldConfig_RecordEditor();
|
2012-02-29 14:47:37 +01:00
|
|
|
|
|
|
|
$grid = new GridField('Companies', 'Companies', new DataList('Company'),$config);
|
|
|
|
return new Form($this,'Form',new FieldList($grid),new FieldList());
|
|
|
|
}
|
2012-04-12 05:04:39 +02:00
|
|
|
}
|