mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
use SilverStripe\ORM\DataList;
|
|
use SilverStripe\FrameworkTest\Model\TestPage;
|
|
class GridFieldTestPage extends TestPage
|
|
{
|
|
|
|
private static $has_one = array(
|
|
"HasOneCompany" => "SilverStripe\\FrameworkTest\\Model\\Company",
|
|
);
|
|
|
|
private static $has_many = array(
|
|
"HasManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company",
|
|
);
|
|
|
|
private static $many_many = array(
|
|
"ManyManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company",
|
|
);
|
|
|
|
public function getCMSFields()
|
|
{
|
|
$fields = parent::getCMSFields();
|
|
|
|
$grids = array();
|
|
|
|
$config = new GridFieldConfig_RecordEditor();
|
|
$grid = new GridField('Companies', 'Companies', new DataList('SilverStripe\\FrameworkTest\\Model\\Company'), $config);
|
|
$fields->addFieldToTab('Root.NoRelation', $grid);
|
|
$grids[] = $grid;
|
|
|
|
$config = new GridFieldConfig_RelationEditor();
|
|
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config);
|
|
$fields->addFieldToTab('Root.HasMany', $grid);
|
|
$grids[] = $grid;
|
|
|
|
$config = new GridFieldConfig_RelationEditor();
|
|
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config);
|
|
$fields->addFieldToTab('Root.ManyMany', $grid);
|
|
$grids[] = $grid;
|
|
|
|
foreach ($grids as $grid) {
|
|
$grid
|
|
->setDescription('This is <strong>bold</strong> help text');
|
|
// ->addExtraClass('cms-description-tooltip');
|
|
}
|
|
|
|
return $fields;
|
|
}
|
|
}
|
|
|
|
class GridFieldTestPage_Controller extends Page_Controller
|
|
{
|
|
|
|
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('SilverStripe\\FrameworkTest\\Model\\Company'), $config);
|
|
return new Form($this, 'Form', new FieldList($grid), new FieldList());
|
|
}
|
|
}
|