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', 'FileUploadRole');
Object::add_extension('SiteTree', 'FrameworkTestSiteTreeExtension');
if(class_exists('SiteTreeCMSWorkflow')) {
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;
}

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