mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 09:06:02 +00:00
4.x compat
This commit is contained in:
parent
d1ba84e843
commit
112bdeea92
@ -36,11 +36,10 @@ class BasicFieldsTestPage extends TestPage
|
|||||||
'GSTNumber' => 'Varchar',
|
'GSTNumber' => 'Varchar',
|
||||||
'OptionSet' => 'Int',
|
'OptionSet' => 'Int',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Dropdown' => 'TestCategory',
|
'Dropdown' => 'TestCategory',
|
||||||
'GroupedDropdown' => 'TestCategory',
|
'GroupedDropdown' => 'TestCategory',
|
||||||
'ListboxField' => 'TestCategory',
|
|
||||||
'File' => 'File',
|
'File' => 'File',
|
||||||
'AttachedFile' => 'File',
|
'AttachedFile' => 'File',
|
||||||
'Image' => 'Image',
|
'Image' => 'Image',
|
||||||
@ -100,7 +99,6 @@ class BasicFieldsTestPage extends TestPage
|
|||||||
'CheckboxSetID' => $firstCat->ID,
|
'CheckboxSetID' => $firstCat->ID,
|
||||||
'DropdownID' => $firstCat->ID,
|
'DropdownID' => $firstCat->ID,
|
||||||
'GroupedDropdownID' => $firstCat->ID,
|
'GroupedDropdownID' => $firstCat->ID,
|
||||||
'ListboxFieldID' => $firstCat->ID,
|
|
||||||
'MultipleListboxFieldID' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
'MultipleListboxFieldID' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
||||||
'OptionSet' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
'OptionSet' => join(',', array($thirdCat->ID, $firstCat->ID)),
|
||||||
'Date' => "2002-10-23",
|
'Date' => "2002-10-23",
|
||||||
@ -112,13 +110,13 @@ class BasicFieldsTestPage extends TestPage
|
|||||||
'DateTimeWithCalendar' => "2002-10-23 23:59",
|
'DateTimeWithCalendar' => "2002-10-23 23:59",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
$fields = parent::getCMSFields();
|
$fields = parent::getCMSFields();
|
||||||
|
|
||||||
$description = 'This is <strong>bold</strong> help text';
|
$description = 'This is <strong>bold</strong> help text';
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Text', array(
|
$fields->addFieldsToTab('Root.Text', array(
|
||||||
Object::create('TextField', 'Required', 'Required field'),
|
Object::create('TextField', 'Required', 'Required field'),
|
||||||
Object::create('TextField', 'Validated', 'Validated field (checks range between 1 and 3)'),
|
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('PhoneNumberField', 'PhoneNumber', 'PhoneNumberField'),
|
||||||
Object::create('CreditCardField', 'CreditCard', 'CreditCardField')
|
Object::create('CreditCardField', 'CreditCard', 'CreditCardField')
|
||||||
));
|
));
|
||||||
|
|
||||||
$fields->addFieldsToTab('Root.Option', array(
|
$fields->addFieldsToTab('Root.Option', array(
|
||||||
Object::create('CheckboxField', 'Checkbox', 'CheckboxField'),
|
Object::create('CheckboxField', 'Checkbox', 'CheckboxField'),
|
||||||
Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()),
|
Object::create('CheckboxSetField', 'CheckboxSet', 'CheckboxSetField', TestCategory::map()),
|
||||||
@ -147,10 +145,7 @@ class BasicFieldsTestPage extends TestPage
|
|||||||
Object::create('GroupedDropdownField', 'GroupedDropdownID',
|
Object::create('GroupedDropdownField', 'GroupedDropdownID',
|
||||||
'GroupedDropdown', array('Test Categorys' => TestCategory::map())
|
'GroupedDropdown', array('Test Categorys' => TestCategory::map())
|
||||||
),
|
),
|
||||||
Object::create('ListboxField', 'ListboxFieldID', 'ListboxField', TestCategory::map())
|
|
||||||
->setSize(3),
|
|
||||||
Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map())
|
Object::create('ListboxField', 'MultipleListboxFieldID', 'ListboxField (multiple)', TestCategory::map())
|
||||||
->setMultiple(true)
|
|
||||||
->setSize(3),
|
->setSize(3),
|
||||||
Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()),
|
Object::create('OptionsetField', 'OptionSet', 'OptionSetField', TestCategory::map()),
|
||||||
Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList(
|
Object::create('ToggleCompositeField', 'ToggleCompositeField', 'ToggleCompositeField', new FieldList(
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
class TestPage extends Page
|
class TestPage extends Page
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We can only create subclasses of TestPage
|
* 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
|
// Don't allow creation other than through requireDefaultRecords
|
||||||
return false;
|
return false;
|
||||||
@ -27,7 +27,7 @@ class TestPage extends Page
|
|||||||
$parent = SiteTree::get()
|
$parent = SiteTree::get()
|
||||||
->filter('URLSegment', 'feature-test-pages')
|
->filter('URLSegment', 'feature-test-pages')
|
||||||
->First();
|
->First();
|
||||||
|
|
||||||
if (!$parent) {
|
if (!$parent) {
|
||||||
$parent = new Page(array(
|
$parent = new Page(array(
|
||||||
'Title' => 'Feature Test Pages',
|
'Title' => 'Feature Test Pages',
|
||||||
@ -60,7 +60,7 @@ class TestPage_Controller extends Page_Controller
|
|||||||
'Form',
|
'Form',
|
||||||
'save',
|
'save',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
|
* 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);
|
$form->loadDataFrom($this->dataRecord);
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save($data, $form)
|
public function save($data, $form)
|
||||||
{
|
{
|
||||||
$form->saveInto($this->dataRecord);
|
$form->saveInto($this->dataRecord);
|
||||||
$this->dataRecord->write();
|
$this->dataRecord->write();
|
||||||
$this->redirectBack();
|
$this->redirectBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function gohome()
|
public function gohome()
|
||||||
{
|
{
|
||||||
$this->redirect("./");
|
$this->redirect("./");
|
||||||
@ -97,7 +97,7 @@ class TestPage_Controller extends Page_Controller
|
|||||||
new FormAction("sendEmail", "Send test email to this address")
|
new FormAction("sendEmail", "Send test email to this address")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function email()
|
public function email()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
@ -105,7 +105,7 @@ class TestPage_Controller extends Page_Controller
|
|||||||
'Form' => $this->EmailForm()
|
'Form' => $this->EmailForm()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendEmail($data, $form)
|
public function sendEmail($data, $form)
|
||||||
{
|
{
|
||||||
$email = new Email();
|
$email = new Email();
|
||||||
@ -114,7 +114,7 @@ class TestPage_Controller extends Page_Controller
|
|||||||
$email->setSubject('A subject with some umlauts: öäüß');
|
$email->setSubject('A subject with some umlauts: öäüß');
|
||||||
$email->setBody('A body with some umlauts: öäüß');
|
$email->setBody('A body with some umlauts: öäüß');
|
||||||
$email->send();
|
$email->send();
|
||||||
|
|
||||||
echo "<p>email sent to " . $data['Email'] . "</p>";
|
echo "<p>email sent to " . $data['Email'] . "</p>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
],
|
],
|
||||||
"require":
|
"require":
|
||||||
{
|
{
|
||||||
"silverstripe/framework": "~3.1",
|
"silverstripe/framework": "~4.0",
|
||||||
"silverstripe/cms": "~3.1"
|
"silverstripe/cms": "~4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user