Backend\FormWidgets\FileUpload
Overview
FileUpload renders a form file uploader field.
Supported options:
file: label: Some file type: fileupload
Extends
Implements
- Larajax\Contracts\ViewComponentInterface
Public Properties
public int $imageWidth
imageWidth for preview
public int $imageHeight
imageHeight for preview
public mixed $fileTypes
fileTypes accepted
public mixed $mimeTypes
mimeTypes accepted
public mixed $maxFilesize
maxFilesize allowed (MB)
public mixed $maxFiles
maxFiles allowed
public string $externalToolbarBus
externalToolbarBus defines a mount point for the editor toolbar. Only works in Vue applications and form document layouts.
public array $thumbOptions
thumbOptions used for generating thumbnails
public boolean $useCaption
useCaption allows the user to set a caption
public bool $deferredBinding
deferredBinding defers the upload action using a session key
Show inherited public properties
Inherited Public Properties
- $model - object for the form. (defined in Backend\Classes\FormWidgetBase)
- $data - containing field values, if none supplied model should be used. (defined in Backend\Classes\FormWidgetBase)
- $sessionKey - for the active session, used for editing forms and deferred bindings. (defined in Backend\Classes\FormWidgetBase)
- $sessionKeySuffix - adds some extra uniqueness to the session key. (defined in Backend\Classes\FormWidgetBase)
- $previewMode - renders this form with uneditable preview data. (defined in Backend\Classes\FormWidgetBase)
- $showLabels - determines if this form field should display comments and labels. (defined in Backend\Classes\FormWidgetBase)
- $implement - extensions for this class. (defined in October\Rain\Extension\Extendable)
- $vars - is a list of variables to pass to the page. (defined in Backend\Classes\WidgetBase)
- $layout - to use for the view. (defined in Backend\Classes\WidgetBase)
- $suppressLayout - prevents the use of a layout. (defined in Backend\Classes\WidgetBase)
- $assetPath - specifies the relative path to the asset directory. (defined in Backend\Classes\WidgetBase)
- $assetUrlPath - specifies the public path to the asset directory. (defined in Backend\Classes\WidgetBase)
- $config - supplied. (defined in Backend\Classes\WidgetBase)
- $alias - defined for this widget. (defined in Backend\Classes\WidgetBase)
- $controller - object. (defined in Backend\Classes\WidgetBase)
Protected Properties
protected $defaultAlias
defaultAlias to identify this widget.
protected Backend\Widgets\Form $configFormWidget
configFormWidget is the embedded form for modifying the properties of the selected file.
protected array $modelsToSave
modelsToSave are models that require saving
Show inherited protected properties
Inherited Protected Properties
- $formField - object containing general form field information. (defined in Backend\Classes\FormWidgetBase)
- $parentForm - The parent form that contains this field. (defined in Backend\Classes\FormWidgetBase)
- $fieldName - (defined in Backend\Classes\FormWidgetBase)
- $valueFrom - Model attribute to get/set value from. (defined in Backend\Classes\FormWidgetBase)
- $extensionData - contains class reflection information, including behaviors. (defined in October\Rain\Extension\Extendable)
- $extendableStaticMethods - is a collection of static methods used by behaviors. (defined in October\Rain\Extension\Extendable)
- $viewPath - specifies a path to the views directory. (defined in Backend\Classes\WidgetBase)
- $layoutPath - specifies a path to the layout directory. (defined in Backend\Classes\WidgetBase)
- $viewPathGuessCache - remembers path guesses for performance. (defined in Backend\Classes\WidgetBase)
- $assets - Collection of assets to display in the layout. (defined in Backend\Classes\WidgetBase)
- $assetBundles - Collection of combined and prioritized assets. (defined in Backend\Classes\WidgetBase)
- $assetDefaults - is the default attributes for assets. (defined in Backend\Classes\WidgetBase)
- $configPath - specifies a path to the config directory. (defined in Backend\Classes\WidgetBase)
- $emitterSingleEventCollection - of events to be fired once only. (defined in Backend\Classes\WidgetBase)
- $emitterEventCollection - of all registered events. (defined in Backend\Classes\WidgetBase)
- $emitterEventSorted - collection. (defined in Backend\Classes\WidgetBase)
- $fatalError - stores the object used for a fatal error. (defined in Backend\Classes\WidgetBase)
Public Methods
public getAcceptedFileTypes()
public getAcceptedFileTypes($includeDot = false): string
getAcceptedFileTypes returns the specified accepted file types, or the default based on the mode. Image mode will return:
- jpg,jpeg,bmp,png,gif,svg
public getConfigFormWidget()
public getConfigFormWidget(): void
getConfigFormWidget for the instantiated Form widget
public getSaveValue()
public getSaveValue($value): void
getSaveValue processes the postback value for this widget. If the value is omitted from postback data, the form widget will be skipped.
public init()
public init(): void
init the widget, called by the constructor and free from its parameters.
public nearestModelAttribute()
public nearestModelAttribute($attribute): void
public onLoadAttachmentConfig()
public onLoadAttachmentConfig(): void
onLoadAttachmentConfig loads the configuration form for an attachment, allowing title and description to be set
public onRemoveAttachment()
public onRemoveAttachment(): void
onRemoveAttachment removes a file attachment
public onSaveAttachmentConfig()
public onSaveAttachmentConfig(): void
onSaveAttachmentConfig commits the changes of the attachment configuration form
public onSortAttachments()
public onSortAttachments(): void
onSortAttachments sorts file attachments
public onUpload()
public onUpload(): void
onUpload handler for the server-side processing of uploaded files
public render()
public render(): void
render the widget's primary contents.
public resolveModelAttribute()
public resolveModelAttribute(string $attribute): array
Returns the final model and attribute name of a nested HTML array attribute. Eg: [$model, $attribute] = $this->resolveModelAttribute($this->valueFrom);
Inherited Public Methods
- __call() - calls an undefined local method. (defined in October\Rain\Extension\Extendable)
- __callStatic() - calls an undefined static method. (defined in October\Rain\Extension\Extendable)
- __construct() - (defined in Backend\Classes\FormWidgetBase)
- __get() - an undefined property. (defined in October\Rain\Extension\Extendable)
- __set() - an undefined property. (defined in October\Rain\Extension\Extendable)
- __sleep() - prepare the object for serialization. (defined in October\Rain\Extension\Extendable)
- __wakeup() - when a model is being unserialized, check if it needs to be booted. (defined in October\Rain\Extension\Extendable)
- addCss() - includes a StyleSheet asset to the asset list. (defined in Backend\Classes\WidgetBase)
- addCssBundle() - includes a CSS asset to the bundled combiner pipeline. (defined in Backend\Classes\WidgetBase)
- addDynamicMethod() - programmatically adds a method to the extendable class. (defined in October\Rain\Extension\Extendable)
- addDynamicProperty() - programmatically adds a property to the extendable class. (defined in October\Rain\Extension\Extendable)
- addJs() - includes a JavaScript asset to the asset list. (defined in Backend\Classes\WidgetBase)
- addJsBundle() - includes a JS asset to the bundled combiner pipeline. (defined in Backend\Classes\WidgetBase)
- addRss() - adds an RSS link asset to the asset list. Call $this->makeAssets(). (defined in Backend\Classes\WidgetBase)
- addViewPath() - prepends a path on the available view path locations. (defined in Backend\Classes\WidgetBase)
- asExtension() - is short hand for
getClassExtension()method, except takes the short. (defined in October\Rain\Extension\Extendable) - bindEvent() - creates a new event binding. (defined in Backend\Classes\WidgetBase)
- bindEventOnce() - creates a new event binding that fires once only. (defined in Backend\Classes\WidgetBase)
- bindToController() - (defined in Backend\Classes\WidgetBase)
- clearExtendedClasses() - (defined in October\Rain\Extension\Extendable)
- combineAssets() - runs asset paths through the Asset Combiner. (defined in Backend\Classes\WidgetBase)
- createIn() - builds a component instance against the given controller, (defined in Backend\Classes\WidgetBase)
- extend() - this class with a closure. (defined in October\Rain\Extension\Extendable)
- extendClassWith() - dynamically extends a class with a specified behavior. (defined in October\Rain\Extension\Extendable)
- extendableCall() - magic method for
__call(). (defined in October\Rain\Extension\Extendable) - extendableCallStatic() - magic method for
__callStatic(). (defined in October\Rain\Extension\Extendable) - extendableConstruct() - should be called as part of the constructor. (defined in October\Rain\Extension\Extendable)
- extendableDestruct() - should be called when serializing the object. (defined in October\Rain\Extension\Extendable)
- extendableExtendCallback() - is a helper method for
::extend()static method. (defined in October\Rain\Extension\Extendable) - extendableGet() - magic method for
__get(). (defined in October\Rain\Extension\Extendable) - extendableSet() - magic method for
__set(). (defined in October\Rain\Extension\Extendable) - fireEvent() - and call the listeners. (defined in Backend\Classes\WidgetBase)
- fireSystemEvent() - fires a combination of local and global events. The first segment is removed. (defined in Backend\Classes\WidgetBase)
- fireViewEvent() - is a special event function used for extending within view files, (defined in Backend\Classes\WidgetBase)
- flushAssets() - disables the use, and subsequent broadcast, of assets. This is useful. (defined in Backend\Classes\WidgetBase)
- getAssetPath() - locates a file based on it's definition. If the file starts with. (defined in Backend\Classes\WidgetBase)
- getAssetPaths() - returns an array of all registered asset paths. (defined in Backend\Classes\WidgetBase)
- getAssetPathsWithAttributes() - returns an array of all registered asset paths. (defined in Backend\Classes\WidgetBase)
- getClassExtension() - returns a behavior object from an extendable class, example:. (defined in October\Rain\Extension\Extendable)
- getClassMethodAsReflector() - (defined in October\Rain\Extension\Extendable)
- getClassMethods() - gets a list of class methods, extension equivalent of get_class_methods(). (defined in October\Rain\Extension\Extendable)
- getConfig() - is a safe accessor for configuration values. (defined in Backend\Classes\WidgetBase)
- getConfigPath() - locates a file based on it's definition. If the file starts with. (defined in Backend\Classes\WidgetBase)
- getController() - returns the controller using this widget. (defined in Backend\Classes\WidgetBase)
- getDynamicProperties() - returns all dynamic properties and their values. (defined in October\Rain\Extension\Extendable)
- getEventHandler() - returns a fully qualified event handler name for this widget. (defined in Backend\Classes\WidgetBase)
- getFatalError() - returns error message. (defined in Backend\Classes\WidgetBase)
- getFieldName() - returns the HTML element field name for this widget, used for. (defined in Backend\Classes\FormWidgetBase)
- getId() - returns a unique ID for this widget. Useful in creating HTML markup. (defined in Backend\Classes\FormWidgetBase)
- getLoadValue() - returns the value for this form field, (defined in Backend\Classes\FormWidgetBase)
- getParentForm() - retrieves the parent form for this formwidget. (defined in Backend\Classes\FormWidgetBase)
- getSessionKey() - returns the active session key, including suffix. (defined in Backend\Classes\FormWidgetBase)
- getViewPath() - locates a file based on its definition. The file name can be prefixed. (defined in Backend\Classes\WidgetBase)
- getViewPaths() - returns the active view path locations. (defined in Backend\Classes\WidgetBase)
- getWidget() - (defined in Backend\Classes\WidgetBase)
- guessConfigPath() - guesses the package path for the called class. (defined in Backend\Classes\WidgetBase)
- guessConfigPathFrom() - guesses the package path from a specified class. (defined in Backend\Classes\WidgetBase)
- guessViewPath() - guesses the package path for the called class. (defined in Backend\Classes\WidgetBase)
- guessViewPathFrom() - guesses the package path from a specified class, including. (defined in Backend\Classes\WidgetBase)
- handleError() - sets standard page variables in the case of a controller error. (defined in Backend\Classes\WidgetBase)
- hasAssetsDefined() - returns true if assets any have been added. (defined in Backend\Classes\WidgetBase)
- hasFatalError() - returns true if a fatal error has been set. (defined in Backend\Classes\WidgetBase)
- implementClassWith() - will implement an extension using non-interference and should. (defined in October\Rain\Extension\Extendable)
- isClassExtendedWith() - checks if extendable class is extended with a behavior object. (defined in October\Rain\Extension\Extendable)
- isClassInstanceOf() - checks if the class implements the supplied interface methods. (defined in October\Rain\Extension\Extendable)
- make() - builds the component and binds it to the current controller. (defined in Backend\Classes\WidgetBase)
- makeAssets() - outputs
<link>and<script>tags to load assets previously added with addJs and addCss method calls. (defined in Backend\Classes\WidgetBase) - makeConfig() - reads the contents of the supplied file and applies it to this object. (defined in Backend\Classes\WidgetBase)
- makeConfigFromArray() - makes a config object from an array, making the first. (defined in Backend\Classes\WidgetBase)
- makeFileContents() - includes a file path using output buffering. (defined in Backend\Classes\WidgetBase)
- makeFormWidget() - object with the supplied form field and widget configuration. (defined in Backend\Classes\WidgetBase)
- makeLayout() - renders a layout. (defined in Backend\Classes\WidgetBase)
- makeLayoutPartial() - renders a layout partial. (defined in Backend\Classes\WidgetBase)
- makePartial() - renders a partial file contents located in the views folder. (defined in Backend\Classes\WidgetBase)
- makeView() - loads a view with the name specified. Applies layout if its name is provided. (defined in Backend\Classes\WidgetBase)
- makeViewContent() - renders supplied contents inside a layout. (defined in Backend\Classes\WidgetBase)
- makeWidget() - object with the supplied configuration file. (defined in Backend\Classes\WidgetBase)
- mergeConfig() - merges two configuration sources, either prepared or not, and returns. (defined in Backend\Classes\WidgetBase)
- methodExists() - checks if a method exists, extension equivalent of method_exists(). (defined in October\Rain\Extension\Extendable)
- propertyExists() - checks if a property exists, extension equivalent of
property_exists(). (defined in October\Rain\Extension\Extendable) - resetFormValue() - from the form field, triggered by the parent form calling
setFormValues. (defined in Backend\Classes\FormWidgetBase) - resetSession() - Resets all session data related to this widget. (defined in Backend\Classes\WidgetBase)
- unbindEvent() - destroys an event binding. (defined in Backend\Classes\WidgetBase)
Protected Methods
protected decorateFileAttributes()
protected decorateFileAttributes($file): System\Models\File
decorateFileAttributes adds the bespoke attributes used internally by this widget. Added attributes are:
- thumbUrl
- pathUrl
protected deferPurgedSaveAttributes()
protected deferPurgedSaveAttributes(
October\Rain\Database\Model $model,
array $attributesToPurge
): void
deferPurgedSaveAttributes removes an array of attributes from the model. If the model implements the Purgeable trait, this is preferred over the internal logic.
protected getCssDimensions()
protected getCssDimensions(): string
getCssDimensions returns the CSS dimensions for the uploaded image, uses auto where no dimension is provided.
protected getDisplayMode()
protected getDisplayMode(): string
getDisplayMode for the file upload. Eg: file-multi, image-single, etc
protected getFileList()
protected getFileList(): void
getFileList returns a list of associated files
protected getFileListFromRelation()
protected getFileListFromRelation(): void
getFileListFromRelation loads the file list from the model relation in memory only if the request is not in a postback state
protected getFileRecord()
protected getFileRecord(): System\Models\File|bool
getFileRecord for this request, returns false if none available
protected getRelationModel()
protected getRelationModel(): Relation
Returns the model of a relation type, supports nesting via HTML array.
protected getRelationObject()
protected getRelationObject(): Relation
Returns the value as a relation object from the model, supports nesting via HTML array.
protected getRelationType()
protected getRelationType(): string
getRelationType returns the value as a relation type from the model, supports nesting via HTML array.
protected getUploadMaxFilesize()
protected getUploadMaxFilesize(): float
getUploadMaxFilesize returns max upload filesize in MB
protected isRelationTypeSingular()
protected isRelationTypeSingular(): bool
isRelationTypeSingular checks if the related model is singular.
protected loadAssets()
protected loadAssets(): void
loadAssets adds widget specific asset files. Use $this->addJs() and $this->addCss() to register new assets to include on the page.
protected performSaveOnModel()
protected performSaveOnModel($model, $data, $options = null): void
performSaveOnModel saves complex data against a model inside a database transaction.
protected prepareModelsToSave()
protected prepareModelsToSave(
October\Rain\Database\Model $model,
array $saveData
): array
prepareModelsToSave takes a model and fills it with data from a multidimensional array. If an attribute is found to be a relationship, that relationship is also filled.
$modelsToSave = $this->prepareModelsToSave($model, [...]);
foreach ($modelsToSave as $modelToSave) {
$modelToSave->save();
}
protected prepareVars()
protected prepareVars(): void
prepareVars for the view data
protected setModelAttributes()
protected setModelAttributes(
October\Rain\Database\Model $model,
array $saveData,
$attrName = ''
): void
setModelAttributes sets a data collection to a model attributes, relations are also set.
protected shouldGenerateThumb()
protected shouldGenerateThumb(): void
shouldGenerateThumb determines if the resizer should be used
Show inherited protected methods
Inherited Protected Methods
- combineBundledAssets() - spins over every bundle definition and combines them to an asset. (defined in Backend\Classes\WidgetBase)
- emitterEventSortEvents() - sorts the listeners for a given event by priority. (defined in Backend\Classes\WidgetBase)
- extendableIsAccessible() - checks if a property is accessible, property equivalent. (defined in October\Rain\Extension\Extendable)
- extensionExtractImplements() - will return classes to implement. (defined in October\Rain\Extension\Extendable)
- extensionExtractMethods() - extracts the available methods from a behavior and adds it. (defined in October\Rain\Extension\Extendable)
- fillFromConfig() - transfers config values stored inside the $config property directly. (defined in Backend\Classes\WidgetBase)
- getAssetEntryBuildPath() - is an internal marker that returns the asset path. (defined in Backend\Classes\WidgetBase)
- getAssetScheme() - is an internal helper to get the asset scheme. (defined in Backend\Classes\WidgetBase)
- getConfigValueFrom() - will apply the config getter convention. (defined in Backend\Classes\WidgetBase)
- getExtendableMethodFromDynamicMethods() - (defined in October\Rain\Extension\Extendable)
- getExtendableMethodFromExtensions() - (defined in October\Rain\Extension\Extendable)
- getLocalPath() - converts a relative path to a local path. (defined in Backend\Classes\WidgetBase)
- getSession() - Retrieves a widget related key/value pair from session data. (defined in Backend\Classes\WidgetBase)
- handleViewException() - handles a view exception. (defined in Backend\Classes\WidgetBase)
- makeSessionId() - Returns a unique session identifier for this widget and controller action. (defined in Backend\Classes\WidgetBase)
- processAssetAttributes() - (defined in Backend\Classes\WidgetBase)
- putSession() - Saves a widget related key/value pair in to session data. (defined in Backend\Classes\WidgetBase)
- readSessionStore() - Reads the widget session store, preferring JSON and falling back to. (defined in Backend\Classes\WidgetBase)
- removeDuplicateAssets() - removes duplicate and global assets from the entire collection. (defined in Backend\Classes\WidgetBase)
- renderAssetAttributes() - takes an asset definition and returns the necessary HTML output. (defined in Backend\Classes\WidgetBase)