Assets

Type
Class
Namespace
craft\fields
Inherits
craft\fields\Assets » craft\fields\BaseRelationField
Since
3.0

Assets represents an Assets field.

View source

Public Properties

PropertyDescription
allowedKindsarray, null – The file kinds that the field should be restricted to (only used if restrictFiles is true)
defaultUploadLocationSourcestring, null – Where files should be uploaded to by default, in format "folder:X", where X is the craft\models\VolumeFolder ID (only used if useSingleFolder is false)
defaultUploadLocationSubpathstring, null – The subpath that files should be uploaded to by default (only used if useSingleFolder is false)
restrictFilesboolean, null – Whether the available assets should be restricted to allowedKinds
singleUploadLocationSourcestring, null – Where files should be restricted to, in format "folder:X", where X is the craft\models\VolumeFolder ID (only used if useSingleFolder is true)
singleUploadLocationSubpathstring, null – The subpath that files should be restricted to (only used if useSingleFolder is true)
useSingleFolderboolean, null – Whether related assets should be limited to a single folder

allowedKinds

Type
array, null

The file kinds that the field should be restricted to (only used if restrictFiles is true)

View source

defaultUploadLocationSource

Type
string, null

Where files should be uploaded to by default, in format "folder:X", where X is the craft\models\VolumeFolder ID (only used if useSingleFolder is false)

View source

defaultUploadLocationSubpath

Type
string, null

The subpath that files should be uploaded to by default (only used if useSingleFolder is false)

View source

restrictFiles

Type
boolean, null

Whether the available assets should be restricted to allowedKinds

View source

singleUploadLocationSource

Type
string, null

Where files should be restricted to, in format "folder:X", where X is the craft\models\VolumeFolder ID (only used if useSingleFolder is true)

View source

singleUploadLocationSubpath

Type
string, null

The subpath that files should be restricted to (only used if useSingleFolder is true)

View source

useSingleFolder

Type
boolean, null

Whether related assets should be limited to a single folder

View source

Protected Properties

allowLargeThumbsView

Type

:

View source

inputJsClass

Type

:

View source

inputTemplate

Type

:

View source

settingsTemplate

Type

:

View source

Public Methods

MethodDescription
_volumeIdBySourceKey()Returns a volume ID from an upload source key.
afterElementSave()
defaultSelectionLabel()
displayName()
getElementValidationRules()
getFileKindOptions()Returns the available file kind options for the settings
getInputHtml()
getSettingsHtml()
getSourceOptions()
init()
isValueEmpty()
normalizeValue()
resolveDynamicPathToFolderId()Resolve source path for uploading for this field.
rules()
validateFileSize()Validates the files to make sure they are one of the allowed file kinds.
validateFileType()Validates the files to make sure they are one of the allowed file kinds.
valueType()

_volumeIdBySourceKey()

Returns a volume ID from an upload source key.

View source

Arguments

Returns

integer, null

afterElementSave()

View source

Arguments

  • $element
  • $isNew

defaultSelectionLabel()

View source

displayName()

View source

getElementValidationRules()

View source

getFileKindOptions()

Returns the available file kind options for the settings

View source

Returns

array

getInputHtml()

View source

Arguments

  • $value
  • $element

getSettingsHtml()

View source

getSourceOptions()

View source

init()

View source

isValueEmpty()

View source

Arguments

  • $value
  • $element

normalizeValue()

View source

Arguments

  • $value
  • $element

resolveDynamicPathToFolderId()

Resolve source path for uploading for this field.

View source

Arguments

Returns

integer

rules()

View source

validateFileSize()

Validates the files to make sure they are one of the allowed file kinds.

View source

Arguments

validateFileType()

Validates the files to make sure they are one of the allowed file kinds.

View source

Arguments

valueType()

View source

Protected Methods

elementType()

View source

inputSelectionCriteria()

View source

inputSources()

View source

Arguments

  • $element

inputTemplateVariables()

View source

Arguments

  • $value
  • $element