4.x compat

This commit is contained in:
Ingo Schommer 2016-04-19 09:27:29 +12:00
parent d1ba84e843
commit 112bdeea92
3 changed files with 15 additions and 20 deletions

View File

@ -36,11 +36,10 @@ class BasicFieldsTestPage extends TestPage
'GSTNumber' => 'Varchar',
'OptionSet' => 'Int',
);
private static $has_one = array(
'Dropdown' => 'TestCategory',
'GroupedDropdown' => 'TestCategory',
'ListboxField' => 'TestCategory',
'File' => 'File',
'AttachedFile' => 'File',
'Image' => 'Image',
@ -100,7 +99,6 @@ class BasicFieldsTestPage extends TestPage
'CheckboxSetID' => $firstCat->ID,
'DropdownID' => $firstCat->ID,
'GroupedDropdownID' => $firstCat->ID,
'ListboxFieldID' => $firstCat->ID,
'MultipleListboxFieldID' => join(',', array($thirdCat->ID, $firstCat->ID)),
'OptionSet' => join(',', array($thirdCat->ID, $firstCat->ID)),
'Date' => "2002-10-23",
@ -112,13 +110,13 @@ class BasicFieldsTestPage extends TestPage
'DateTimeWithCalendar' => "2002-10-23 23:59",
);
}
public function getCMSFields()
{
$fields = parent::getCMSFields();
$description = 'This is <strong>bold</strong> help text';
$fields->addFieldsToTab('Root.Text', array(
Object::create('TextField', 'Required', 'Required field'),
Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'),
@ -138,7 +136,7 @@ class BasicFieldsTestPage extends TestPage
Object::create('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'),
Object::create('CreditCardField', 'CreditCard', 'CreditCardField')
));
$fields->addFieldsToTab('Root.Option', array(
Object::create('CheckboxField', 'Checkbox', 'CheckboxField'),
Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()),
@ -147,10 +145,7 @@ class BasicFieldsTestPage extends TestPage
Object::create('GroupedDropdownField', 'GroupedDropdownID',
'GroupedDropdown', array('Test Categorys' => TestCategory::map())
),
Object::create('ListboxField', 'ListboxFieldID', 'ListboxField', TestCategory::map())
->setSize(3),
Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map())
->setMultiple(true)
->setSize(3),
Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()),
Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList(

View File

@ -5,11 +5,11 @@
*/
class TestPage extends Page
{
/**
* We can only create subclasses of TestPage
*/
public function canCreate($member = null)
public function canCreate($member = null, $context = array())
{
// Don't allow creation other than through requireDefaultRecords
return false;
@ -27,7 +27,7 @@ class TestPage extends Page
$parent = SiteTree::get()
->filter('URLSegment', 'feature-test-pages')
->First();
if (!$parent) {
$parent = new Page(array(
'Title' => 'Feature Test Pages',
@ -60,7 +60,7 @@ class TestPage_Controller extends Page_Controller
'Form',
'save',
);
/**
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
*/
@ -76,14 +76,14 @@ class TestPage_Controller extends Page_Controller
$form->loadDataFrom($this->dataRecord);
return $form;
}
public function save($data, $form)
{
$form->saveInto($this->dataRecord);
$this->dataRecord->write();
$this->redirectBack();
}
public function gohome()
{
$this->redirect("./");
@ -97,7 +97,7 @@ class TestPage_Controller extends Page_Controller
new FormAction("sendEmail", "Send test email to this address")
));
}
public function email()
{
return array(
@ -105,7 +105,7 @@ class TestPage_Controller extends Page_Controller
'Form' => $this->EmailForm()
);
}
public function sendEmail($data, $form)
{
$email = new Email();
@ -114,7 +114,7 @@ class TestPage_Controller extends Page_Controller
$email->setSubject('A subject with some umlauts: öäüß');
$email->setBody('A body with some umlauts: öäüß');
$email->send();
echo "<p>email sent to " . $data['Email'] . "</p>";
}
}

View File

@ -12,7 +12,7 @@
],
"require":
{
"silverstripe/framework": "~3.1",
"silverstripe/cms": "~3.1"
"silverstripe/framework": "~4.0",
"silverstripe/cms": "~4.0"
}
}