MINOR: add TestFileUploadPage and FileUploadRole to test a simple file upload field and a simple image upload field can be saved in case of Assets folder and / or Assets/Uploads folder missing. related with open ticket #4942(http://open.silverstripe.org/ticket/4942).

This commit is contained in:
Normann Lou 2010-01-28 07:26:00 +00:00
parent ba454f7f18
commit 8600386ae5
3 changed files with 44 additions and 1 deletions

View File

@ -1,3 +1,6 @@
<?php
Object::add_extension('Member', 'FrameworkTestRole');
Object::add_extension('Member', 'FileUploadRole');
?>

View File

@ -0,0 +1,28 @@
<?php
class TestFileUploadPage extends TestPage{
}
class TestFileUploadPage_Controller extends TestPage_Controller{
function Form(){
$fields = new FieldSet(
new EmailField('Email', 'EmailField'),
new FileField('AFile','FileField'),
new SimpleImageField('AImage','SimpleImageField')
);
$actions = new FieldSet(
new FormAction('addMember', "Add a member with two Files uploaded")
);
return new Form($this, "Form", $fields, $actions);
}
function addMember($data, $form){
$member = new Member();
$form->saveInto($member);
$member->write();
Director::redirectBack();
}
}

View File

@ -0,0 +1,12 @@
<?php
class FileUploadRole extends DataObjectDecorator{
function extraStatics() {
return array(
'has_one' => array(
'AFile' => 'File',
'AImage' => 'Image',
),
);
}
}
?>