Ownership on GridFieldTestPage

This commit is contained in:
Ingo Schommer 2017-07-06 14:25:33 +12:00
parent d2711a82bb
commit 46891b2dea

View File

@ -24,6 +24,11 @@ class GridFieldTestPage extends TestPage
"ManyManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company", "ManyManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company",
); );
private static $owns = [
'HasOneCompany',
'HasManyCompanies',
];
public function getCMSFields() public function getCMSFields()
{ {
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
@ -32,25 +37,22 @@ class GridFieldTestPage extends TestPage
$config = new GridFieldConfig_RecordEditor(); $config = new GridFieldConfig_RecordEditor();
$grid = new GridField('Companies', 'Companies', new DataList('SilverStripe\\FrameworkTest\\Model\\Company'), $config); $grid = new GridField('Companies', 'Companies', new DataList('SilverStripe\\FrameworkTest\\Model\\Company'), $config);
$grid->setDescription('Records are NOT owned by the page, and need to be individually published');
$fields->addFieldToTab('Root.NoRelation', $grid); $fields->addFieldToTab('Root.NoRelation', $grid);
$grids[] = $grid; $grids[] = $grid;
$config = new GridFieldConfig_RelationEditor(); $config = new GridFieldConfig_RelationEditor();
$grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config); $grid = new GridField('HasManyCompanies', 'HasManyCompanies', $this->HasManyCompanies(), $config);
$grid->setDescription('Records are owned by the page, so should auto-publish');
$fields->addFieldToTab('Root.HasMany', $grid); $fields->addFieldToTab('Root.HasMany', $grid);
$grids[] = $grid; $grids[] = $grid;
$config = new GridFieldConfig_RelationEditor(); $config = new GridFieldConfig_RelationEditor();
$grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config); $grid = new GridField('ManyManyCompanies', 'ManyManyCompanies', $this->ManyManyCompanies(), $config);
$grid->setDescription('Records are NOT owned by the page, and need to be individually published');
$fields->addFieldToTab('Root.ManyMany', $grid); $fields->addFieldToTab('Root.ManyMany', $grid);
$grids[] = $grid; $grids[] = $grid;
foreach ($grids as $grid) {
$grid
->setDescription('This is <strong>bold</strong> help text');
// ->addExtraClass('cms-description-tooltip');
}
return $fields; return $fields;
} }
} }