2008-10-03 00:05:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class RelationFieldsTestPage extends TestPage {
|
2012-02-29 14:47:37 +01:00
|
|
|
|
2013-03-26 11:44:04 +01:00
|
|
|
private static $has_one = array(
|
2012-02-29 14:47:37 +01:00
|
|
|
"HasOneCompany" => "Company",
|
2012-03-08 10:36:12 +01:00
|
|
|
"HasOnePage" => "SiteTree",
|
2013-04-06 13:44:24 +02:00
|
|
|
"HasOnePageWithSearch" => "SiteTree",
|
2008-10-03 00:05:45 +02:00
|
|
|
);
|
2013-03-26 11:44:04 +01:00
|
|
|
private static $has_many = array(
|
2012-02-29 14:47:37 +01:00
|
|
|
"HasManyCompanies" => "Company",
|
2012-03-08 10:36:12 +01:00
|
|
|
"HasManyPages" => "SiteTree",
|
2008-10-03 00:05:45 +02:00
|
|
|
);
|
2013-03-26 11:44:04 +01:00
|
|
|
private static $many_many = array(
|
2012-02-29 14:47:37 +01:00
|
|
|
"ManyManyCompanies" => "Company",
|
2012-03-08 10:36:12 +01:00
|
|
|
"ManyManyPages" => "SiteTree",
|
2009-01-30 06:01:28 +01:00
|
|
|
);
|
2012-08-29 09:44:26 +02:00
|
|
|
|
2013-03-26 11:44:04 +01:00
|
|
|
private static $defaults = array(
|
2012-08-29 09:44:26 +02:00
|
|
|
'Title' => 'Relational Fields'
|
|
|
|
);
|
2008-10-03 00:05:45 +02:00
|
|
|
|
2012-04-13 15:59:19 +02:00
|
|
|
function getCMSFields() {
|
2008-10-03 00:05:45 +02:00
|
|
|
$fields = parent::getCMSFields();
|
2012-11-30 12:08:46 +01:00
|
|
|
|
|
|
|
$allFields = array();
|
2008-10-03 00:05:45 +02:00
|
|
|
|
2012-11-30 12:08:46 +01:00
|
|
|
$checkboxFields = array(
|
2012-03-08 10:36:12 +01:00
|
|
|
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())
|
2012-02-29 14:47:37 +01:00
|
|
|
);
|
2012-11-30 12:08:46 +01:00
|
|
|
$fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
|
|
|
|
$allFields += $checkboxFields;
|
2009-01-30 06:01:28 +01:00
|
|
|
|
2012-11-30 12:08:46 +01:00
|
|
|
$treeFields = array(
|
2013-04-06 13:44:24 +02:00
|
|
|
TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'),
|
|
|
|
TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true),
|
2012-04-12 11:56:25 +02:00
|
|
|
TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'),
|
|
|
|
TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)
|
2012-11-30 12:08:46 +01:00
|
|
|
);
|
|
|
|
$fields->addFieldsToTab('Root.Tree', $treeFields);
|
|
|
|
$allFields += $treeFields;
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-10-03 00:05:45 +02:00
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class RelationFieldsTestPage_Controller extends TestPage_Controller {
|
|
|
|
|
2012-04-12 05:04:39 +02:00
|
|
|
}
|