2008-10-03 00:05:45 +02:00
|
|
|
<?php
|
|
|
|
|
2016-07-01 04:37:50 +02:00
|
|
|
use SilverStripe\FrameworkTest\Model\TestCategory;
|
|
|
|
use SilverStripe\FrameworkTest\Model\TestPage;
|
|
|
|
use SilverStripe\FrameworkTest\Model\TestPage_Controller;
|
2016-09-07 07:10:55 +02:00
|
|
|
use SilverStripe\Forms\CheckboxSetField;
|
|
|
|
use SilverStripe\Forms\TreeDropdownField;
|
|
|
|
use SilverStripe\Forms\TreeMultiselectField;
|
|
|
|
|
2016-07-01 04:37:50 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class RelationFieldsTestPage extends TestPage
|
|
|
|
{
|
2017-11-27 08:24:08 +01:00
|
|
|
private static $table_name = 'RelationFieldsTestPage';
|
2016-07-01 04:37:50 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
private static $has_one = array(
|
2016-07-01 04:37:50 +02:00
|
|
|
"HasOneCompany" => "SilverStripe\\FrameworkTest\\Model\\Company",
|
2016-08-16 06:38:31 +02:00
|
|
|
"HasOnePage" => "SilverStripe\\CMS\\Model\\SiteTree",
|
|
|
|
"HasOnePageWithSearch" => "SilverStripe\\CMS\\Model\\SiteTree",
|
2015-12-17 21:20:49 +01:00
|
|
|
);
|
|
|
|
private static $has_many = array(
|
2016-07-01 04:37:50 +02:00
|
|
|
"HasManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company",
|
2016-08-16 06:38:31 +02:00
|
|
|
"HasManyPages" => "SilverStripe\\CMS\\Model\\SiteTree",
|
2015-12-17 21:20:49 +01:00
|
|
|
);
|
|
|
|
private static $many_many = array(
|
2016-07-01 04:37:50 +02:00
|
|
|
"ManyManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company",
|
2016-08-16 06:38:31 +02:00
|
|
|
"ManyManyPages" => "SilverStripe\\CMS\\Model\\SiteTree",
|
2015-12-17 21:20:49 +01:00
|
|
|
);
|
2012-08-29 09:44:26 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
private static $defaults = array(
|
|
|
|
'Title' => 'Relational Fields'
|
|
|
|
);
|
2017-11-27 08:24:08 +01:00
|
|
|
|
2024-08-15 03:15:22 +02:00
|
|
|
private static array $scaffold_cms_fields_settings = [
|
|
|
|
'ignoreFields' => [
|
|
|
|
'HasOneCompany',
|
|
|
|
],
|
|
|
|
'ignoreRelations' => [
|
|
|
|
'HasManyCompanies',
|
|
|
|
'ManyManyCompanies',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public function getCMSFields()
|
|
|
|
{
|
|
|
|
$fields = parent::getCMSFields();
|
2012-11-30 12:08:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$allFields = array();
|
2017-11-27 08:24:08 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$checkboxFields = array(
|
|
|
|
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())
|
|
|
|
);
|
|
|
|
$fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
|
|
|
|
$allFields += $checkboxFields;
|
2009-01-30 06:01:28 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$treeFields = array(
|
2016-08-16 06:38:31 +02:00
|
|
|
TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SilverStripe\\CMS\\Model\\SiteTree'),
|
|
|
|
TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SilverStripe\\CMS\\Model\\SiteTree')->setShowSearch(true),
|
|
|
|
TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SilverStripe\\CMS\\Model\\SiteTree'),
|
|
|
|
TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SilverStripe\\CMS\\Model\\SiteTree')->setShowSearch(true)
|
2015-12-17 21:20:49 +01:00
|
|
|
);
|
|
|
|
$fields->addFieldsToTab('Root.Tree', $treeFields);
|
|
|
|
$allFields += $treeFields;
|
2012-11-30 12:08:46 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
foreach ($allFields as $field) {
|
|
|
|
$field
|
|
|
|
->setDescription('This is <strong>bold</strong> help text')
|
|
|
|
->addExtraClass('cms-help');
|
|
|
|
// ->addExtraClass('cms-help cms-help-tooltip');
|
|
|
|
}
|
2009-01-30 06:01:28 +01:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
return $fields;
|
|
|
|
}
|
2008-10-03 00:05:45 +02:00
|
|
|
}
|
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class RelationFieldsTestPage_Controller extends TestPage_Controller
|
|
|
|
{
|
2012-04-12 05:04:39 +02:00
|
|
|
}
|