diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index 2806598..aeef01d 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -9,6 +9,7 @@ class BasicFieldsTestPage extends TestPage { 'CalendarDate' => 'Date', 'CompositeDate' => 'Date', 'Date' => 'Date', + "DateDisabled" => "Date", 'DMYCalendarDate' => 'Date', 'DMYDate' => 'Date', 'DropdownTime' => 'Time', @@ -46,6 +47,7 @@ class BasicFieldsTestPage extends TestPage { static $defaults = array( 'Readonly' => 'Default value for \'readonly\'', + "DateDisabled" => "2002-10-23", ); function getCMSFields() { @@ -83,6 +85,7 @@ class BasicFieldsTestPage extends TestPage { new CalendarDateField('CalendarDate','CalendarDateField'), new CompositeDateField('CompositeDate','CompsiteDateField'), new DateField('Date','DateField'), + new DateField_Disabled("DateDisabled","DateField_Disabled (should be 2002-10-23)"), new DMYCalendarDateField('DMYCalendarDate','DMYCalendarDateField'), new DMYDateField('DMYDate','DMYDateField'), new DropdownTimeField('DropdownTime','DropdownTimeField'), @@ -114,4 +117,4 @@ class BasicFieldsTestPage_Controller extends TestPage_Controller { } } -?> \ No newline at end of file +?> diff --git a/code/TestPage.php b/code/TestPage.php index 2384d5f..c2dce3c 100644 --- a/code/TestPage.php +++ b/code/TestPage.php @@ -31,6 +31,21 @@ class TestPage extends Page { * Parent class of all test page controllers */ class TestPage_Controller extends Page_Controller { + /** + * This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context + */ + function Form() { + $fields = $this->getCMSFields(); + $actions = new FieldSet(new FormAction("save", "Save")); + $form = new Form($this, "Form", $fields, $actions); + $form->loadDataFrom($this->dataRecord); + return $form; + } + function save($data, $form) { + $form->saveInto($this->dataRecord); + $this->dataRecord->write(); + Director::redirectBack(); + } } ?> \ No newline at end of file