ENHANCEMENt Added tree-based fields

This commit is contained in:
Ingo Schommer 2012-03-08 10:36:12 +01:00
parent e815c5bf09
commit fbf955f602
4 changed files with 27 additions and 14 deletions

View File

@ -2,6 +2,7 @@
Object::add_extension('Member', 'FrameworkTestRole'); Object::add_extension('Member', 'FrameworkTestRole');
Object::add_extension('Member', 'FileUploadRole'); Object::add_extension('Member', 'FileUploadRole');
Object::add_extension('SiteTree', 'FrameworkTestSiteTreeExtension');
if(class_exists('SiteTreeCMSWorkflow')) { if(class_exists('SiteTreeCMSWorkflow')) {
Object::add_extension('SiteConfig', 'CMSWorkflowSiteConfigDecorator'); Object::add_extension('SiteConfig', 'CMSWorkflowSiteConfigDecorator');

View File

@ -127,6 +127,8 @@ class BasicFieldsTestPage extends TestPage {
} }
} }
$fields->addFieldToTab('Root.Text', new TextField('Text_NoLabel', false, 'TextField without label'), 'Text_disabled');
return $fields; return $fields;
} }

View File

@ -0,0 +1,11 @@
<?php
class FrameworkTestSiteTreeExtension extends DataExtension {
function extraStatics() {
return array(
'has_one' => array('RelationFieldsTestPage' => 'RelationFieldsTestPage'),
'belongs_many_many' => array('RelationFieldsTestPages' => 'RelationFieldsTestPage'),
);
}
}

View File

@ -4,35 +4,34 @@ class RelationFieldsTestPage extends TestPage {
static $has_one = array( static $has_one = array(
"HasOneCompany" => "Company", "HasOneCompany" => "Company",
"HasOnePage" => "SiteTree",
); );
static $has_many = array( static $has_many = array(
"HasManyCompanies" => "Company", "HasManyCompanies" => "Company",
"HasManyPages" => "SiteTree",
); );
static $many_many = array( static $many_many = array(
"ManyManyCompanies" => "Company", "ManyManyCompanies" => "Company",
"ManyManyPages" => "SiteTree",
); );
function getCMSFields() { function getCMSFields() {
$fields = parent::getCMSFields(); $fields = parent::getCMSFields();
$fields->addFieldToTab("Root.CheckboxSet", $fields->addFieldToTab("Root.CheckboxSet",
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())); new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())
$fields->addFieldToTab("Root.CTF",
new ComplexTableField($this, "HasManyCompanies", "TestCTFItem")
); );
// TODO Fix legacy relation CTFs in 3.0 $fields->addFieldsToTab('Root.Tree', array(
Object::create('TreeDropdownField', 'HasOnePage', 'HasOnePage', 'SiteTree'),
// $fields->addFieldToTab("Root.HasOneCTF", Object::create('TreeMultiselectField', 'HasManyPages', 'HasManyPages', 'SiteTree'),
// new HasOneComplexTableField($this, "HasOneCompany"); Object::create('TreeMultiselectField', 'ManyManyPages', 'ManyManyPages (with search)', 'SiteTree')->setShowSearch(true)
));
// $fields->addFieldToTab("Root.HasManyCTF",
// new HasManyComplexTableField($this, "HasManyCompanies");
// $fields->addFieldToTab("Root.ManyManyCTF",
// new ManyManyComplexTableField($this, "ManyManyCompanies");
// TODO Fix CTF in 3.0
// $fields->addFieldToTab("Root.CTF",
// new ComplexTableField($this, "HasManyCompanies", "TestCTFItem")
// );
// $fields->addFieldToTab("Root.Tests.ComplexTableField", // $fields->addFieldToTab("Root.Tests.ComplexTableField",
// new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map())); // new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));