SilverStripe\AssetAdmin\Forms\UploadField
Represents a file upload field with ReactJS based frontend.
Allows writing to a parent record with the following relation types:
- has_one
- has_many
- many_many
Additionally supports writing directly to the File table not attached
to any parent record.
Synopsis
class UploadField
extends FormField
implements
FileHandleField
{
- // members
- private static array $allowed_actions = ;
- private static integer $thumbnail_width = 60;
- private static integer $thumbnail_height = 60;
- protected bool $uploadEnabled = true;
- protected bool $attachEnabled = true;
- protected null|int $allowedMaxFileNumber = NULL;
- protected string $inputType = 'file';
- protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_CUSTOM;
- protected string $schemaComponent = 'UploadField';
- protected bool|null $multiUpload = NULL;
- // methods
- public void __construct()
- public void getSchemaDataDefaults()
- public HTTPResponse upload()
- protected int getFolderID()
- public void getSchemaStateDefaults()
- protected array getEncodedItems()
- public bool getIsMultiUpload()
- public $this setIsMultiUpload()
- public null|int getAllowedMaxFileNumber()
- public null|int getAllowedMaxFileSize()
- public $this setAllowedMaxFileNumber()
- public void getAttributes()
- public void Type()
- public void performReadonlyTransformation()
- public void performDisabledTransformation()
- public bool validate()
- public bool getUploadEnabled()
- public $this setUploadEnabled()
- public bool getAttachEnabled()
- public UploadField setAttachEnabled()
Hierarchy
Extends
- SilverStripe\Forms\FormField
Uses
- SilverStripe\Forms\FileUploadReceiver
Implements
- SilverStripe\Forms\FileHandleField
Members
private
- $allowed_actions — array
- $thumbnail_height — int
- $thumbnail_width — int
protected
- $allowedMaxFileNumber
—
SilverStripe\AssetAdmin\Forms\null|int
The number of files allowed for this field - $attachEnabled
—
SilverStripe\AssetAdmin\Forms\bool
Set if selecting existing files is enabled. - $inputType
- $multiUpload — SilverStripe\AssetAdmin\Forms\bool|null
- $schemaComponent
- $schemaDataType
- $uploadEnabled
—
SilverStripe\AssetAdmin\Forms\bool
Set if uploading new files is enabled.
Methods
protected
- getEncodedItems() — Encode selected values for react
- getFolderID() — Get ID of target parent folder
public
- __construct() — Create a new file field.
- Type()
- getAllowedMaxFileNumber() — Gets the number of files allowed for this field
- getAllowedMaxFileSize() — Returns the max allowed filesize
- getAttachEnabled() — Check if attaching files is enabled
- getAttributes()
- getIsMultiUpload() — Check if allowed to upload more than one file
- getSchemaDataDefaults()
- getSchemaStateDefaults()
- getUploadEnabled() — Check if uploading files is enabled
- performDisabledTransformation()
- performReadonlyTransformation()
- setAllowedMaxFileNumber() — Sets the number of files allowed for this field
- setAttachEnabled() — Set if attaching files is enabled
- setIsMultiUpload() — Set upload type to multiple or single
- setUploadEnabled() — Set if uploading files is enabled
- upload() — Creates a single file based on a form-urlencoded upload.
- validate() — Checks if the number of files attached adheres to the $allowedMaxFileNumber defined