Class UploadField
Field for uploading single or multiple files of all types, including images. NOTE: this Field will call write() on the supplied record
Features (some might not be available to old browsers):
- File Drag&Drop support
- Progressbar
- Image thumbnail/file icons even before upload finished
- Saving into relations
- Edit file
- allowedExtensions is by default File::$allowed_extensions
- maxFileSize the value of min(upload_max_filesize,
post_max_size) from php.ini
<>Usage
- Object
-
ViewableData
implements
IteratorAggregate
-
RequestHandler
-
FormField
-
FileField
-
UploadField
Author: Zauberfisch
Example: <code> $UploadField = new UploadField('myFiles', 'Please upload some images <span>(max. 5 files)</span>'); $UploadField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png', 'gif')); $UploadField->setConfig('allowedMaxFileNumber', 5); </code>
Located at sapphire/forms/UploadField.php
Methods summary
public
|
|
public
|
#
setTemplateFileButtons( String $template )
Set name of template used for Buttons on each file (replace, edit, remove, delete) (without path or extension) |
public
String
|
|
public
|
#
setTemplateFileEdit( String $template )
Set name of template used for the edit (inline & popup) of a file file (without path or extension) |
public
String
|
|
public
|
#
setRecord(
Force a record to be used as "Parent" for uploaded Files (eg a Page with a has_one to File) |
public
|
|
public
|
|
public
|
|
protected
|
|
public
|
|
public
mixed
|
|
public
|
|
protected
string
|
|
public
array
|
|
public
string
|
#
extraClass( )
Compiles all CSS-classes. Optionally includes a "nolabel"-class if no title
was set on the formfield. Uses |
public
string
|
#
Field( array $properties = array() )
Returns the form field - used by templates. Although FieldHolder is generally what is inserted into templates, all of the field holder templates make use of $Field. It's expected that FieldHolder will give you the "complete" representation of the field on the form, whereas Field will give you the core editing widget, such as an input tag. |
public
|
|
public
|
|
public
|
|
public
|
|
public
string
|
|
public
|
|
protected
|
|
public
|
|
public
boolean
|
#
managesRelation( )
Determines if the underlying record (if any) has a relationship matching the field name. Important for permission control. |
public
string
|
|
public
boolean
|
|
public
boolean
|
|
public
|
|
public
|
Methods inherited from FileField
Value(),
getFolderName(),
getUpload(),
getValidator(),
saveInto(),
setFolderName(),
setUpload(),
setValidator()
Methods inherited from FormField
FieldHolder(),
ID(),
LeftTitle(),
Link(),
Message(),
MessageType(),
Name(),
Required(),
RightTitle(),
SmallFieldHolder(),
Title(),
Type(),
addExtraClass(),
attrTitle(),
attrValue(),
createTag(),
dataValue(),
debug(),
describe(),
forTemplate(),
getAttribute(),
getAttributesHTML(),
getCustomValidationMessage(),
getDescription(),
getFieldHolderTemplate(),
getFieldHolderTemplates(),
getForm(),
getName(),
getSmallFieldHolderTemplate(),
getSmallFieldHolderTemplates(),
getTabIndex(),
getTemplate(),
getTemplates(),
hasClass(),
hasData(),
isComposite(),
isReadonly(),
name_to_label(),
performDisabledTransformation(),
removeExtraClass(),
rootFieldList(),
rootFieldSet(),
securityTokenEnabled(),
setAttribute(),
setContainerFieldList(),
setContainerFieldSet(),
setCustomValidationMessage(),
setDescription(),
setDisabled(),
setError(),
setFieldHolderTemplate(),
setForm(),
setLeftTitle(),
setName(),
setReadonly(),
setRightTitle(),
setSmallFieldHolderTemplate(),
setTabIndex(),
setTemplate(),
setTitle(),
setValue(),
transform()
Methods inherited from RequestHandler
allowedActions(),
checkAccessAction(),
getRequest(),
handleRequest(),
hasAction(),
httpError(),
isAjax(),
setDataModel(),
setRequest()
Methods inherited from ViewableData
ATT_val(),
CSSClasses(),
Debug(),
JS_val(),
Me(),
RAW_val(),
SQL_val(),
ThemeDir(),
XML_val(),
__get(),
__isset(),
__set(),
buildCastingCache(),
cachedCall(),
castingClass(),
castingHelper(),
castingHelperPair(),
castingObjectCreator(),
castingObjectCreatorPair(),
customise(),
defineMethods(),
escapeTypeForField(),
getField(),
getIterator(),
getXMLValues(),
hasField(),
hasValue(),
obj(),
renderWith(),
setCustomisedObj(),
setField()
Methods inherited from Object
__call(),
__toString(),
addMethodsFrom(),
addStaticVars(),
addWrapperMethod(),
add_extension(),
add_static_var(),
allMethodNames(),
cacheToFile(),
clearCache(),
combined_static(),
config(),
create(),
createMethod(),
create_from_string(),
exists(),
extend(),
getCustomClass(),
getExtensionInstance(),
getExtensionInstances(),
get_extensions(),
get_extra_config_sources(),
get_static(),
hasExtension(),
hasMethod(),
has_extension(),
invokeWithExtensions(),
is_a(),
loadCache(),
parentClass(),
parse_class_spec(),
remove_extension(),
sanitiseCachename(),
saveCache(),
set_stat(),
set_static(),
set_uninherited(),
stat(),
static_lookup(),
strong_create(),
uninherited(),
uninherited_static(),
useCustomClass()
Magic methods summary
Properties summary
public static
array
|
$allowed_actions | |
public static
array
|
$url_handlers | |
protected
String
|
$templateFileButtons | |
protected
String
|
$templateFileEdit | |
protected
|
$record | |
protected
|
$items | |
protected
array
|
$ufConfig |
#
Config for this field used in both, php and javascript (will be merged into the config of the javascript file upload plugin). See framework/_config/uploadfield.yml for configuration defaults and documentation. |
Properties inherited from FileField
$allowedExtensions,
$allowedMaxFileSize,
$folderName,
$relationAutoSetting,
$upload
Properties inherited from FormField
$attributes,
$containerFieldList,
$customValidationMessage,
$description,
$disabled,
$dontEscape,
$extraClass,
$extraClasses,
$fieldHolderTemplate,
$form,
$leftTitle,
$message,
$messageType,
$name,
$readonly,
$rightTitle,
$smallFieldHolderTemplate,
$template,
$title,
$value
Properties inherited from RequestHandler
$brokenOnConstruct,
$model,
$request
Properties inherited from ViewableData
$casting,
$customisedObject,
$default_cast,
$failover
Comments
Use the Silverstripe Forum to ask questions.