2010-01-28 08:26:00 +01:00
|
|
|
<?php
|
|
|
|
|
2016-07-01 04:37:50 +02:00
|
|
|
use SilverStripe\FrameworkTest\Model\TestPage;
|
|
|
|
use SilverStripe\FrameworkTest\Model\TestPage_Controller;
|
2016-07-20 00:34:52 +02:00
|
|
|
use SilverStripe\Security\Member;
|
2016-09-07 07:10:55 +02:00
|
|
|
use SilverStripe\Forms\EmailField;
|
|
|
|
use SilverStripe\Forms\FileField;
|
2019-05-07 02:00:07 +02:00
|
|
|
use SilverStripe\AssetAdmin\Forms\UploadField;
|
2016-09-07 07:10:55 +02:00
|
|
|
use SilverStripe\Forms\FieldList;
|
|
|
|
use SilverStripe\Forms\FormAction;
|
|
|
|
use SilverStripe\Forms\Form;
|
|
|
|
|
2016-07-01 04:37:50 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class TestFileUploadPage extends TestPage
|
|
|
|
{
|
2017-11-27 08:24:08 +01:00
|
|
|
private static $table_name = 'TestFileUploadPage';
|
2010-01-28 08:26:00 +01:00
|
|
|
}
|
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
class TestFileUploadPage_Controller extends TestPage_Controller
|
|
|
|
{
|
|
|
|
private static $allowed_actions = array(
|
|
|
|
'Form'
|
|
|
|
);
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public function Form()
|
|
|
|
{
|
|
|
|
$fields = new FieldList(
|
|
|
|
new EmailField('Email', 'EmailField'),
|
|
|
|
new FileField('AFile', 'FileField'),
|
|
|
|
$aImage = new UploadField('AImage', 'SimpleImageField')
|
|
|
|
);
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$aImage->allowedExtensions = array('jpg', 'gif', 'png');
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
$actions = new FieldList(
|
|
|
|
new FormAction('addMember', "Add a member with two Files uploaded")
|
|
|
|
);
|
|
|
|
return new Form($this, "Form", $fields, $actions);
|
|
|
|
}
|
2016-07-20 00:34:52 +02:00
|
|
|
|
2015-12-17 21:20:49 +01:00
|
|
|
public function addMember($data, $form)
|
|
|
|
{
|
|
|
|
$member = new Member();
|
|
|
|
$form->saveInto($member);
|
|
|
|
$member->write();
|
|
|
|
$this->redirectBack();
|
|
|
|
}
|
2014-02-17 22:12:52 +01:00
|
|
|
}
|