mirror of
https://github.com/silverstripe/silverstripe-frameworktest
synced 2024-10-22 11:06:02 +02:00
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:
parent
ba454f7f18
commit
8600386ae5
@ -1,3 +1,6 @@
|
||||
<?php
|
||||
|
||||
Object::add_extension('Member', 'FrameworkTestRole');
|
||||
Object::add_extension('Member', 'FileUploadRole');
|
||||
|
||||
?>
|
28
code/TestFileUploadPage.php
Normal file
28
code/TestFileUploadPage.php
Normal 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();
|
||||
}
|
||||
}
|
12
code/model/FileUploadRole.php
Normal file
12
code/model/FileUploadRole.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
class FileUploadRole extends DataObjectDecorator{
|
||||
function extraStatics() {
|
||||
return array(
|
||||
'has_one' => array(
|
||||
'AFile' => 'File',
|
||||
'AImage' => 'Image',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user