class FormFile extends FormComponent

Class FormFile

Properties

protected array $config from  FormBase
bool $save_requires_edit_var from  FormBase
Form $form from  FormComponent
protected $field_disable_save

Set to false if this field is not "saveable", e.g. static test

from  FormBase
$REQUEST_VARS from  FormComponent
$name from  FormComponent
callable|bool $db_handler from  FormComponent
Controller $mod
protected string $file_select
protected string|bool $file_name
protected string|bool $file_path
array $image_mimes

Methods

__construct()

FormFile constructor.

append(string $name, mixed $value, bool|string $key = false)

No description

from  FormBase
void
concat(string $name, string $value)

No description

from  FormBase
bool
delete_file()

No description

mixed
destroy($name)

No description

from  FormBase
string
display_field(string $fieldname, bool|string $default_value = false)

No description

string
display_field_print(string $fieldname, string $default_value = false)

Display field in print mode

mixed
get(string $name)

No description

from  FormBase
array|null
getAcceptedExtensions()

Returns the previously set file extensions or system wide if not set

array
getConfig()

No description

from  FormBase
string
getContentType()

Returns the content type.

string
getDomSelector()

Return Dom Selector for this field within the current form (This is NOT necessary unique if you are having 2 forms with identical names in form and field names

callable
getDownloadHandler()

Returns a download handler.

string
getElementVisibilityClass()

Get Element Visibility Class Formerly known as tag class

bool
getHideOptions()

Returns whether to display upload options or not.

bool
getIsVisible()

Determine visibilty based on user input on dependent fields

string
getLabel()

Get Field label

string|null
getLocation()

Returns a relative location path.

int
getMaxHeight()

Returns a maximum height for images.

int
getMaxUploadSize()

Returns the maximum upload size.

int
getMaxWidth()

Returns a maximum width for images.

string
getMime()

Returns the supported mime types.

bool
getSaveInCascadedFolder()

This option is used by the replace location with id method.

mixed
getUploadCallback()

Returns the upload callback.

bool
getUseSystemDMS()

Returns whether the system dms will be used for storing or not.

string|null
getWebDir()

Returns the storage path where to save files.

string
get_description()

No description

mixed
get_display_value()

returns the displayed value

array
get_group(string $prefix)

No description

from  FormBase
array
get_properties()

No description

from  FormBase
array|bool
get_validation_options()

No description

get_value()

No description

bool
hasCombinedInputFields()

Does this component use combined input fields which required special handling from form?

bool
hasRequiredStyle()

Return if the component should be shown as required with specified style class.

string|null
hasThumbnail()

Returns TRUE if a thumbnail should be displayed.

void
init()

Initialize

init_obj()

Initializes the form base

from  FormBase
$this
insertAfter(FormComponent $formComponent = null)

Insert this field after the specified field

$this
insertBefore(FormComponent $formComponent = null)

Insert this field before the specified field

bool
isReadonly()

Returns TRUE if field is readonly, FALSE otherwise.

bool
is_displayed()

Checks if the field is hidden by a tag. It is important when validating

from  FormBase
void
post_process()

No description

void
process()

No description

string
render(string|false $name = false, string|false $value = false)

No description

mixed
save()

Move File to Final Location and return the filename

$this
set(string $propertyName, mixed $propertyValue)

No description

from  FormBase
setAcceptedExtensions(array $extensions)

The accepted file extensions.

$this
setCSSClassName(string $class = null)

Set Field Row CSS class name

setContentType(string $type)

Sets the content type.

$this
setCustomErrorText(string $error_msg)

Show Custom Error Message for this field

setDefaultValue(mixed $value = null)

Set Field default value

$this
setDescriptionText(string $description = null)

Set Field Help Text

setDownloadHandler(callable $callable)

Sets a download handler.

$this
setGridClass(string $gridClass = null)

Set Flexbox Grid Class

$this
setHelpText(string $help = null)

Set Field Help Text

setHideOptions(bool $bool)

Sets whether to display upload options or not.

$this
setIsDBField(bool $bool = true)

Field is to be loaded from and saved to database.

$this
setIsI18NField(bool $bool = true)

Field is considered to be translatable. This is usually determined automatically reading the instance configuration of the calling instance

$this
setIsReadonly(bool $bool = true)

Consider Field as readonly

$this
setIsRequired(bool $bool = true, bool $onlyRequiredIfVisible = true)

Consider Field as required

$this
setLabel(string $label = '', string $icon_class = null)

Set Field label

$this
setLabelIconClass(string $icon_class = '')

Set label icon class

setLocation(string $location)

Sets a relative location path.

setMaxHeight(int $height)

Sets a maximum height for images.

setMaxUploadSize(int $size)

Sets the maximum upload size.

setMaxWidth(int $width)

Sets a maximum width for images.

setMime(string $mimes)

Sets mime type.

$this
setPopulateField(FormComponent $target, string $dataURL = null)

Manipulate another fields data when the value of the current field changes.

$this
setPrefixHTML(string $html = null)

Add Custom HTML before the field element

setSaveInCascadedFolder(bool $bool)

Set TRUE to use cascaded folder.

$this
setSuffixHTML(string $html = null)

Add Custom HTML after the field element

setThumbnail(bool $bool)

Sets whether a thumbnail should be displayed or not.

setUploadCallback(callable $callback)

Sets a upload callback.

setUseSystemDMS(bool $bool)

Sets whether the system dms will be used for storing or not.

$this
setVisibilityDependsOn(FormComponent $formComponent = null, array $matchingValues = [])

Set Visibility Dependency if you want your field only to be shown if another field has a specify value Array Syntax: tag, tag_source

$this
setVisibilityIsSource(bool $bool = true)

Set field to be the event source for another dependent field. Changes of this fields values will trigger events to their dependent fields and change their visibility in the frontend

setWebDir(string $webDir)

Sets the path to the storage where to save files on upload.

set_display_value(mixed $value)

set the displayed value

void
set_properties(array $array)

No description

from  FormBase
set_request_vars($request)

No description

array
validate()

Validate, Check MimeTypes

bool
validateInFrontendAsRequired()

Should this field be marked with HTML5 required attribute? HTML5 required should not be used when field may be hidden, as it might still be required frontend-wise, even if hidden!

bool
validateInRequestAsRequired()

Should this field be treated as required during request validation?

Details

at line 49
__construct()

FormFile constructor.

in FormBase at line 198
append(string $name, mixed $value, bool|string $key = false)

No description

Parameters

string $name

property name

mixed $value

property value

bool|string $key

key of property array

in FormBase at line 183
void concat(string $name, string $value)

No description

Parameters

string $name

of the property

string $value

to be concated

Return Value

void

at line 1095
protected bool delete_file()

No description

Return Value

bool

in FormBase at line 168
mixed destroy($name)

No description

Parameters

$name

Return Value

mixed

last value

at line 494
string display_field(string $fieldname, bool|string $default_value = false)

No description

Parameters

string $fieldname fieldname
bool|string $default_value

Default Value

Return Value

string

at line 718
string display_field_print(string $fieldname, string $default_value = false)

Display field in print mode

Parameters

string $fieldname
string $default_value

Return Value

string

in FormBase at line 77
mixed get(string $name)

No description

Parameters

string $name

name of the property

Return Value

mixed

at line 150
array|null getAcceptedExtensions()

Returns the previously set file extensions or system wide if not set

Return Value

array|null

in FormBase at line 84
array getConfig()

No description

Return Value

array

at line 307
string getContentType()

Returns the content type.

Return Value

string

in FormComponent at line 588
string getDomSelector()

Return Dom Selector for this field within the current form (This is NOT necessary unique if you are having 2 forms with identical names in form and field names

Return Value

string

Exceptions

Exception

at line 286
callable getDownloadHandler()

Returns a download handler.

Return Value

callable

in FormComponent at line 600
protected string getElementVisibilityClass()

Get Element Visibility Class Formerly known as tag class

Return Value

string

at line 265
bool getHideOptions()

Returns whether to display upload options or not.

Return Value

bool

in FormComponent at line 501
bool getIsVisible()

Determine visibilty based on user input on dependent fields

Return Value

bool

True if considered visible

in FormComponent at line 317
string getLabel()

Get Field label

Return Value

string

at line 92
string|null getLocation()

Returns a relative location path.

The relative location path is used to determine the exact destination path inside of the web dir.

Return Value

string|null

at line 403
int getMaxHeight()

Returns a maximum height for images.

This value is used for image uploads to restrict the size of an image.

Return Value

int

at line 230
int getMaxUploadSize()

Returns the maximum upload size.

Return Value

int

at line 373
int getMaxWidth()

Returns a maximum width for images.

This value is used for image uploads to restrict the size of an image.

Return Value

int

at line 119
string getMime()

Returns the supported mime types.

The returned value can contains multiple mime types which are separated by comma.

Return Value

string

at line 416
bool getSaveInCascadedFolder()

This option is used by the replace location with id method.

Returns TRUE if the id should be cascaded (e.g. k1 for 10.000 - 19.999)

Return Value

bool

See also

\XELOS\Framework\XF\UI\Form\FormFile::replace_location_id()
File::get_cascaded_folder

at line 330
mixed getUploadCallback()

Returns the upload callback.

The callback is called before the upload starts.

Return Value

mixed

at line 172
bool getUseSystemDMS()

Returns whether the system dms will be used for storing or not.

Return Value

bool

at line 197
string|null getWebDir()

Returns the storage path where to save files.

If this form component does not provide a web dir then this method will return the web dir defined in the form or null if no one is defined.

Return Value

string|null

in FormComponent at line 156
string get_description()

No description

Return Value

string

html or false if no description is set

in FormComponent at line 257
mixed get_display_value()

returns the displayed value

Return Value

mixed value

in FormBase at line 217
array get_group(string $prefix)

No description

Parameters

string $prefix

prefix (e.g. mygroup_ )

Return Value

array

in FormBase at line 92
array get_properties()

No description

Return Value

array

in FormComponent at line 56
array|bool get_validation_options()

No description

Return Value

array|bool

validation options, false on failure

in FormComponent at line 175
get_value()

No description

in FormComponent at line 48
bool hasCombinedInputFields()

Does this component use combined input fields which required special handling from form?

Return Value

bool

in FormComponent at line 651
protected bool hasRequiredStyle()

Return if the component should be shown as required with specified style class.

Return Value

bool

at line 244
string|null hasThumbnail()

Returns TRUE if a thumbnail should be displayed.

Return Value

string|null

at line 441
void init()

Initialize

Return Value

void

in FormBase at line 39
init_obj()

Initializes the form base

in FormComponent at line 549
$this insertAfter(FormComponent $formComponent = null)

Insert this field after the specified field

Parameters

FormComponent $formComponent

Return Value

$this

in FormComponent at line 534
$this insertBefore(FormComponent $formComponent = null)

Insert this field before the specified field

Parameters

FormComponent $formComponent

Return Value

$this

in FormComponent at line 374
bool isReadonly()

Returns TRUE if field is readonly, FALSE otherwise.

Return Value

bool

in FormBase at line 237
bool is_displayed()

Checks if the field is hidden by a tag. It is important when validating

Return Value

bool

at line 1033
void post_process()

No description

Return Value

void

at line 462
void process()

No description

Return Value

void

in FormComponent at line 187
string render(string|false $name = false, string|false $value = false)

No description

Parameters

string|false $name
string|false $value

Return Value

string

at line 926
mixed save()

Move File to Final Location and return the filename

Return Value

mixed

in FormBase at line 104
$this set(string $propertyName, mixed $propertyValue)

No description

Parameters

string $propertyName

propoerty name

mixed $propertyValue

property value

Return Value

$this

at line 141
FormFile setAcceptedExtensions(array $extensions)

The accepted file extensions.

Parameters

array $extensions

= ['xls','xlsx','filextension']

Return Value

FormFile

in FormComponent at line 396
$this setCSSClassName(string $class = null)

Set Field Row CSS class name

Parameters

string $class

e.g. hide_label, error

Return Value

$this

at line 318
FormFile setContentType(string $type)

Sets the content type.

Parameters

string $type

Return Value

FormFile

in FormComponent at line 564
$this setCustomErrorText(string $error_msg)

Show Custom Error Message for this field

Parameters

string $error_msg

Return Value

$this

in FormComponent at line 385
FormComponent setDefaultValue(mixed $value = null)

Set Field default value

Parameters

mixed $value

Return Value

FormComponent

in FormComponent at line 418
$this setDescriptionText(string $description = null)

Set Field Help Text

Parameters

string $description

String to help people understand this fields value and options

Return Value

$this

at line 297
FormFile setDownloadHandler(callable $callable)

Sets a download handler.

Parameters

callable $callable

Return Value

FormFile

in FormComponent at line 578
$this setGridClass(string $gridClass = null)

Set Flexbox Grid Class

Parameters

string $gridClass

Example: xcol-6_md-12

Return Value

$this

in FormComponent at line 407
$this setHelpText(string $help = null)

Set Field Help Text

Parameters

string $help

String to help people fill out your form

Return Value

$this

at line 276
FormFile setHideOptions(bool $bool)

Sets whether to display upload options or not.

Parameters

bool $bool

Return Value

FormFile

in FormComponent at line 341
$this setIsDBField(bool $bool = true)

Field is to be loaded from and saved to database.

Parameters

bool $bool

Return Value

$this

in FormComponent at line 354
$this setIsI18NField(bool $bool = true)

Field is considered to be translatable. This is usually determined automatically reading the instance configuration of the calling instance

Parameters

bool $bool

Return Value

$this

in FormComponent at line 365
$this setIsReadonly(bool $bool = true)

Consider Field as readonly

Parameters

bool $bool

Return Value

$this

in FormComponent at line 330
$this setIsRequired(bool $bool = true, bool $onlyRequiredIfVisible = true)

Consider Field as required

Parameters

bool $bool
bool $onlyRequiredIfVisible

If field is used with dependent visibility we consider the field only required when the field was visible to the user

Return Value

$this

in FormComponent at line 293
$this setLabel(string $label = '', string $icon_class = null)

Set Field label

Parameters

string $label
string $icon_class

CSS Icon class, e.g. icon-time

Return Value

$this

in FormComponent at line 308
$this setLabelIconClass(string $icon_class = '')

Set label icon class

Parameters

string $icon_class

CSS Icon class, e.g. icon-time

Return Value

$this

at line 106
FormFile setLocation(string $location)

Sets a relative location path.

The relative location path is used to determine the exact destination path inside of the web dir.

Parameters

string $location

Return Value

FormFile

at line 390
FormFile setMaxHeight(int $height)

Sets a maximum height for images.

This value is used for image uploads to restrict the size of an image. This should be used in combination with width.

Parameters

int $height

Return Value

FormFile

See also

FormFile::setMaxWidth

at line 220
FormFile setMaxUploadSize(int $size)

Sets the maximum upload size.

Parameters

int $size Bytes

Return Value

FormFile

at line 360
FormFile setMaxWidth(int $width)

Sets a maximum width for images.

This value is used for image uploads to restrict the size of an image. This should be used in combination with height.

Parameters

int $width

Return Value

FormFile

at line 130
FormFile setMime(string $mimes)

Sets mime type.

Parameters

string $mimes

One or more separated by comma.

Return Value

FormFile

in FormComponent at line 453
$this setPopulateField(FormComponent $target, string $dataURL = null)

Manipulate another fields data when the value of the current field changes.

Common usage: Populate a second select once user chooses from the first select

Parameters

FormComponent $target
string $dataURL

Return Value

$this

in FormComponent at line 429
$this setPrefixHTML(string $html = null)

Add Custom HTML before the field element

Parameters

string $html

e.g. 'http:// '

Return Value

$this

at line 433
FormFile setSaveInCascadedFolder(bool $bool)

Set TRUE to use cascaded folder.

Cascaded folder are used to avoid long id folder names. This is used by replace id in location method.

Parameters

bool $bool

Return Value

FormFile

See also

\XELOS\Framework\XF\UI\Form\FormFile::replace_location_id()
File::get_cascaded_folder

in FormComponent at line 440
$this setSuffixHTML(string $html = null)

Add Custom HTML after the field element

Parameters

string $html

e.g. ' hours'

Return Value

$this

at line 255
FormFile setThumbnail(bool $bool)

Sets whether a thumbnail should be displayed or not.

Parameters

bool $bool

Return Value

FormFile

at line 344
FormFile setUploadCallback(callable $callback)

Sets a upload callback.

The callback is called before the upload starts. The callback will be called with params "tmp_name" as first and "name" as second function param.

Parameters

callable $callback

Return Value

FormFile

at line 183
FormFile setUseSystemDMS(bool $bool)

Sets whether the system dms will be used for storing or not.

Parameters

bool $bool

Return Value

FormFile

in FormComponent at line 467
$this setVisibilityDependsOn(FormComponent $formComponent = null, array $matchingValues = [])

Set Visibility Dependency if you want your field only to be shown if another field has a specify value Array Syntax: tag, tag_source

Parameters

FormComponent $formComponent

Null will reset and remove all existing dependencies

array $matchingValues

Field will be shown/visible if the dependent field contains/has one of the values specified

Return Value

$this

in FormComponent at line 491
$this setVisibilityIsSource(bool $bool = true)

Set field to be the event source for another dependent field. Changes of this fields values will trigger events to their dependent fields and change their visibility in the frontend

Fields are automatically set to be a source if used in a call of setVisibilityDependsOn()

Array Syntax: tag_source

Parameters

bool $bool

Return Value

$this

at line 208
FormFile setWebDir(string $webDir)

Sets the path to the storage where to save files on upload.

Parameters

string $webDir

Return Value

FormFile

in FormComponent at line 248
set_display_value(mixed $value)

set the displayed value

Parameters

mixed $value value

in FormBase at line 153
void set_properties(array $array)

No description

Parameters

array $array

associated array like property=>value

Return Value

void

in FormComponent at line 40
set_request_vars($request)

No description

Parameters

$request

at line 727
array validate()

Validate, Check MimeTypes

Return Value

array

Returns an array with error message strings. Empty array if no errors exist

in FormComponent at line 639
protected bool validateInFrontendAsRequired()

Should this field be marked with HTML5 required attribute? HTML5 required should not be used when field may be hidden, as it might still be required frontend-wise, even if hidden!

Return Value

bool

in FormComponent at line 624
protected bool validateInRequestAsRequired()

Should this field be treated as required during request validation?

Return Value

bool