mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
BUGFIX Updated existing test fields to work with 3.0
This commit is contained in:
parent
796851cad0
commit
42ffea6317
@ -40,12 +40,16 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
'OptionSet' => 'TestCategory',
|
'OptionSet' => 'TestCategory',
|
||||||
'GroupedDropdown' => 'TestCategory',
|
'GroupedDropdown' => 'TestCategory',
|
||||||
'ListboxField' => 'TestCategory',
|
'ListboxField' => 'TestCategory',
|
||||||
'Image' => 'Image',
|
|
||||||
'Image2' => 'Image',
|
|
||||||
'Image3' => 'Image',
|
|
||||||
'File' => 'File',
|
'File' => 'File',
|
||||||
'File2' => 'File',
|
'Image' => 'Image',
|
||||||
'File3' => 'File',
|
);
|
||||||
|
|
||||||
|
static $has_many = array(
|
||||||
|
'HasManyFiles' => 'File',
|
||||||
|
);
|
||||||
|
|
||||||
|
static $many_many = array(
|
||||||
|
'ManyManyFiles' => 'File',
|
||||||
);
|
);
|
||||||
|
|
||||||
static $defaults = array(
|
static $defaults = array(
|
||||||
@ -58,7 +62,7 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Content.TextTests', array(
|
$fields->addFieldsToTab('Root.Text', array(
|
||||||
new ReadonlyField('Readonly', 'ReadonlyField'),
|
new ReadonlyField('Readonly', 'ReadonlyField'),
|
||||||
new TextareaField('Textarea', 'TextareaField - 8 rows', 8),
|
new TextareaField('Textarea', 'TextareaField - 8 rows', 8),
|
||||||
new TextField('Text', 'TextField'),
|
new TextField('Text', 'TextField'),
|
||||||
@ -68,15 +72,16 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
new AjaxUniqueTextField('AjaxUniqueText', 'AjaxUniqueTextField', 'AjaxUniqueText', 'BasicFieldsTestPage'),
|
new AjaxUniqueTextField('AjaxUniqueText', 'AjaxUniqueTextField', 'AjaxUniqueText', 'BasicFieldsTestPage'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Content.NumericTests', array(
|
$fields->addFieldsToTab('Root.Numeric', array(
|
||||||
new NumericField('Number', 'NumericField'),
|
new NumericField('Number', 'NumericField'),
|
||||||
new CurrencyField('Price', 'CurrencyField'),
|
new CurrencyField('Price', 'CurrencyField'),
|
||||||
new PhoneNumberField('PhoneNumber', 'PhoneNumberField'),
|
new PhoneNumberField('PhoneNumber', 'PhoneNumberField'),
|
||||||
new CreditCardField('CreditCard', 'CreditCardField')
|
new CreditCardField('CreditCard', 'CreditCardField')
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Content.OptionTests', array(
|
$fields->addFieldsToTab('Root.Option', array(
|
||||||
new CheckboxField('Checkbox', 'CheckboxField'),
|
new CheckboxField('Checkbox', 'CheckboxField'),
|
||||||
|
new CheckboxSetField('CheckboxSet', 'CheckboxSetField', TestCategory::map()),
|
||||||
new DropdownField('DropdownID', 'DropdownField', TestCategory::map()),
|
new DropdownField('DropdownID', 'DropdownField', TestCategory::map()),
|
||||||
new GroupedDropdownField('GroupedDropdownID', 'GroupedDropdown', array('Test Categorys' => TestCategory::map())),
|
new GroupedDropdownField('GroupedDropdownID', 'GroupedDropdown', array('Test Categorys' => TestCategory::map())),
|
||||||
new ListboxField('ListboxFieldID', 'ListboxField', TestCategory::map(), array(), 3),
|
new ListboxField('ListboxFieldID', 'ListboxField', TestCategory::map(), array(), 3),
|
||||||
@ -84,7 +89,7 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
));
|
));
|
||||||
|
|
||||||
// All these date/time fields generally have issues saving directly in the CMS
|
// All these date/time fields generally have issues saving directly in the CMS
|
||||||
$fields->addFieldsToTab('Root.Content.DateTimeTests', array(
|
$fields->addFieldsToTab('Root.DateTime', array(
|
||||||
$calendarDateField = new DateField('CalendarDate','DateField with calendar'),
|
$calendarDateField = new DateField('CalendarDate','DateField with calendar'),
|
||||||
new DateField('Date','DateField'),
|
new DateField('Date','DateField'),
|
||||||
new DateField_Disabled("DateDisabled","DateField (disabled)"),
|
new DateField_Disabled("DateDisabled","DateField (disabled)"),
|
||||||
@ -102,13 +107,11 @@ class BasicFieldsTestPage extends TestPage {
|
|||||||
$dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
|
$dateTimeShowCalendar->getDateField()->setConfig('showcalendar', true);
|
||||||
$dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
|
$dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true);
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Content.FileTests', array(
|
$fields->addFieldsToTab('Root.File', array(
|
||||||
new ImageField('Image','ImageField'),
|
FormField::create('UploadField', 'File','FileUploadField'),
|
||||||
new SimpleImageField('Image2','SimpleImageField'),
|
FormField::create('UploadField', 'Image','ImageUploadField'),
|
||||||
new ImageField('Image3','ImageField'),
|
FormField::create('UploadField', 'HasManyFiles','HasManyFilesUploadField'),
|
||||||
new FileIFrameField('File','FileIFrameField'),
|
FormField::create('UploadField', 'ManyManyFiles','ManyManyFilesUploadField')
|
||||||
new FileField('File2','FileField'),
|
|
||||||
new FileIFrameField('File3','FileIFrameField'),
|
|
||||||
));
|
));
|
||||||
|
|
||||||
return $fields;
|
return $fields;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Test a subtree-admin that only shows the children of a FTPageHolder
|
* Test a subtree-admin that only shows the children of a FTPageHolder
|
||||||
*/
|
*/
|
||||||
class CMSSubTreeAdmin extends CMSMain {
|
class CMSSubTreeAdmin extends CMSPagesController {
|
||||||
// These variables are 2.3-specific; in 2.2.x you will need to edit _config.php
|
// These variables are 2.3-specific; in 2.2.x you will need to edit _config.php
|
||||||
static $url_segment = 'subtree';
|
static $url_segment = 'subtree';
|
||||||
static $menu_title = 'FT Pages';
|
static $menu_title = 'FT Pages';
|
||||||
@ -16,10 +16,6 @@ class CMSSubTreeAdmin extends CMSMain {
|
|||||||
$ftRoot->write();
|
$ftRoot->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This code is what you will need to do to make a subtree version of CMSMain
|
|
||||||
$this->generateDataTreeHints();
|
|
||||||
$this->generateTreeStylingJS();
|
|
||||||
|
|
||||||
// ftRoot->ID is your root node
|
// ftRoot->ID is your root node
|
||||||
$siteTree = $this->getSiteTreeFor("SiteTree", $ftRoot->ID);
|
$siteTree = $this->getSiteTreeFor("SiteTree", $ftRoot->ID);
|
||||||
|
|
||||||
|
@ -14,29 +14,29 @@ class RelationFieldsTestPage extends TestPage {
|
|||||||
function getCMSFields() {
|
function getCMSFields() {
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$fields->addFieldToTab("Root.Content.CheckboxSet",
|
$fields->addFieldToTab("Root.CheckboxSet",
|
||||||
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
|
new CheckboxSetField("CheckboxSet", "CheckboxSetField", TestCategory::map()));
|
||||||
|
|
||||||
/*
|
$fields->addFieldToTab("Root.CTF",
|
||||||
$fields->addFieldToTab("Root.Content.ComplexTableField",
|
|
||||||
new ComplexTableField($this, "Items", "TestCTFItem", array(
|
new ComplexTableField($this, "Items", "TestCTFItem", array(
|
||||||
"Title" => "Item Title",
|
"Title" => "Item Title",
|
||||||
"Author" => "Item Author")));
|
"Author" => "Item Author")));
|
||||||
*/
|
|
||||||
|
|
||||||
$fields->addFieldToTab("Root.Content.HasOneComplexTableField",
|
// TODO Fix legacy relation CTFs in 3.0
|
||||||
new HasOneComplexTableField($this, "FavouriteItem", "TestCTFItem", array(
|
|
||||||
"Title" => "Item Title",
|
|
||||||
"Author" => "Item Author")));
|
|
||||||
|
|
||||||
$fields->addFieldToTab("Root.Content.HasManyComplexTableField",
|
// $fields->addFieldToTab("Root.HasOneCTF",
|
||||||
new HasManyComplexTableField($this, "Items", "TestCTFItem", array(
|
// new HasOneComplexTableField($this, "FavouriteItem", "TestCTFItem", array(
|
||||||
"Title" => "Item Title",
|
// "Title" => "Item Title",
|
||||||
"Author" => "Item Author")));
|
// "Author" => "Item Author")));
|
||||||
|
|
||||||
$fields->addFieldToTab("Root.Content.ManyManyComplexTableField",
|
// $fields->addFieldToTab("Root.HasManyCTF",
|
||||||
new ManyManyComplexTableField($this, "CheckboxSet", "TestCategory", array(
|
// new HasManyComplexTableField($this, "Items", "TestCTFItem", array(
|
||||||
"Title" => "Item Title")));
|
// "Title" => "Item Title",
|
||||||
|
// "Author" => "Item Author")));
|
||||||
|
|
||||||
|
// $fields->addFieldToTab("Root.ManyManyCTF",
|
||||||
|
// new ManyManyComplexTableField($this, "CheckboxSet", "TestCategory", array(
|
||||||
|
// "Title" => "Item Title")));
|
||||||
|
|
||||||
|
|
||||||
// $fields->addFieldToTab("Root.Tests.ComplexTableField",
|
// $fields->addFieldToTab("Root.Tests.ComplexTableField",
|
||||||
|
@ -16,7 +16,7 @@ class TestCategory extends DataObject {
|
|||||||
*/
|
*/
|
||||||
static function map() {
|
static function map() {
|
||||||
$categories = DataObject::get('TestCategory');
|
$categories = DataObject::get('TestCategory');
|
||||||
if($categories) return $categories->map('ID', 'Title');
|
if($categories) return $categories->map('ID', 'Title')->toArray();
|
||||||
else return array();
|
else return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user