2012-02-29 14:47:37 +01:00
|
|
|
<?php
|
2015-12-17 21:20:49 +01:00
|
|
|
class GridFieldTestPage extends TestPage
|
|
|
|
{
|
2012-02-29 16:06:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
private static $has_one = array(
|
|
|
|
"HasOneCompany" => "Company",
|
|
|
|
);
|
2012-02-29 16:06:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
private static $has_many = array(
|
|
|
|
"HasManyCompanies" => "Company",
|
|
|
|
);
|
2012-02-29 16:06:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
private static $many_many = array(
|
|
|
|
"ManyManyCompanies" => "Company",
|
|
|
|
);
|
|
|
|
|
|
|
|
public function getCMSFields()
|
|
|
|
{
|
|
|
|
$fields = parent::getCMSFields();
|
2012-02-29 14:47:37 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$grids = array();
|
2012-11-30 12:08:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$config = new GridFieldConfig_RecordEditor();
|
|
|
|
$grid = new GridField('Companies', 'Companies', new DataList('Company'), $config);
|
|
|
|
$fields->addFieldToTab('Root.NoRelation', $grid);
|
|
|
|
$grids[] = $grid;
|
2012-02-29 14:47:37 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$config = new GridFieldConfig_RelationEditor();
|
|
|
|
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config);
|
|
|
|
$fields->addFieldToTab('Root.HasMany', $grid);
|
|
|
|
$grids[] = $grid;
|
2012-02-29 16:06:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$config = new GridFieldConfig_RelationEditor();
|
|
|
|
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config);
|
|
|
|
$fields->addFieldToTab('Root.ManyMany', $grid);
|
|
|
|
$grids[] = $grid;
|
2012-11-30 12:08:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
foreach ($grids as $grid) {
|
|
|
|
$grid
|
|
|
|
->setDescription('This is <strong>bold</strong> help text');
|
|
|
|
// ->addExtraClass('cms-description-tooltip');
|
|
|
|
}
|
2012-02-29 14:47:37 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
return $fields;
|
|
|
|
}
|
2012-02-29 14:47:37 +01:00
|
|
|
}
|
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class GridFieldTestPage_Controller extends Page_Controller
|
|
|
|
{
|
2014-02-17 22:04:11 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
private static $allowed_actions = array(
|
|
|
|
'Form',
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
public $Title = "GridFieldTestPage";
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
parent::init();
|
|
|
|
Requirements::css('frameworktest/css/gridfieldtest.css', 'screen');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return Form
|
|
|
|
*/
|
|
|
|
public function Form()
|
|
|
|
{
|
|
|
|
$config = new GridFieldConfig_RecordEditor();
|
|
|
|
|
|
|
|
$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
|
|
|
}
|