silverstripe-frameworktest/code/RelationFieldsTestPage.php

63 lines
2.1 KiB
PHP
Raw Normal View History

2008-10-03 00:05:45 +02:00
<?php
use SilverStripe\FrameworkTest\Model\TestCategory;
use SilverStripe\FrameworkTest\Model\TestPage;
use SilverStripe\FrameworkTest\Model\TestPage_Controller;
2015-12-17 21:20:49 +01:00
class RelationFieldsTestPage extends TestPage
{
2015-12-17 21:20:49 +01:00
private static $has_one = array(
"HasOneCompany" => "SilverStripe\\FrameworkTest\\Model\\Company",
2015-12-17 21:20:49 +01:00
"HasOnePage" => "SiteTree",
"HasOnePageWithSearch" => "SiteTree",
);
private static $has_many = array(
"HasManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company",
2015-12-17 21:20:49 +01:00
"HasManyPages" => "SiteTree",
);
private static $many_many = array(
"ManyManyCompanies" => "SilverStripe\\FrameworkTest\\Model\\Company",
2015-12-17 21:20:49 +01:00
"ManyManyPages" => "SiteTree",
);
2015-12-17 21:20:49 +01:00
private static $defaults = array(
'Title' => 'Relational Fields'
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
2015-12-17 21:20:49 +01:00
$allFields = array();
$checkboxFields = array(
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())
);
$fields->addFieldsToTab("Root.CheckboxSet", $checkboxFields);
$allFields += $checkboxFields;
2015-12-17 21:20:49 +01:00
$treeFields = array(
TreeDropdownField::create('HasOnePageID', 'HasOnePage', 'SiteTree'),
TreeDropdownField::create('HasOnePageWithSearchID', 'HasOnePageWithSearch', 'SiteTree')->setShowSearch(true),
TreeMultiselectField::create('HasManyPages', 'HasManyPages', 'SiteTree'),
TreeMultiselectField::create('ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)
);
$fields->addFieldsToTab('Root.Tree', $treeFields);
$allFields += $treeFields;
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');
}
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
}