Class File
Responsibility: init, pre-dispatch and render <input>
HTML element with type file
. File
field has it's own validator Files
to check everything necessary for uploaded files and check files by accept
attribute rules by magic bytes.
-
MvcCore\Ext\Forms\Field
implements
MvcCore\Ext\Forms\IField
uses
MvcCore\Ext\Forms\Field\Props,
MvcCore\Ext\Forms\Field\Getters,
MvcCore\Ext\Forms\Field\Setters,
MvcCore\Ext\Forms\Field\Rendering
-
MvcCore\Ext\Forms\Fields\File
implements
MvcCore\Ext\Forms\Fields\IVisibleField,
MvcCore\Ext\Forms\Fields\ILabel,
MvcCore\Ext\Forms\Fields\IMultiple,
MvcCore\Ext\Forms\Fields\IFile,
MvcCore\Ext\Forms\Fields\IAlwaysValidate
uses
MvcCore\Ext\Forms\Field\Props\VisibleField,
MvcCore\Ext\Forms\Field\Props\Label,
MvcCore\Ext\Forms\Field\Props\Multiple,
MvcCore\Ext\Forms\Field\Props\Files,
MvcCore\Ext\Forms\Field\Props\Wrapper
Methods summary
public
MvcCore\Ext\Forms\Fields\Select
|
#
SetForm( MvcCore\Ext\IForm $form )
This INTERNAL method is called from \MvcCore\Ext\Form after field
is added into form instance by $form->AddField(); method. Do not
use this method even if you don't develop any form field.
- Check if field has any name, which is required.
- Set up form and field id attribute by form id and field name.
- Set up required.
- Set up translate boolean property.
- Check if there is defined any value for accept attribute to validate uploaded files.
- Check if form has correct enctype attribute for uploading files.
This INTERNAL method is called from \MvcCore\Ext\Form after field
is added into form instance by $form->AddField(); method. Do not
use this method even if you don't develop any form field.
- Check if field has any name, which is required.
- Set up form and field id attribute by form id and field name.
- Set up required.
- Set up translate boolean property.
- Check if there is defined any value for accept attribute to validate uploaded files.
- Check if form has correct enctype attribute for uploading files.
Parameters
Returns
Throws
InvalidArgumentException
Overrides
|
protected
|
#
checkConfiguration( )
Check configuration against PHP ini
values and between each other.
If there is any error, thrown an exception.
Check configuration against PHP ini
values and between each other.
If there is any error, thrown an exception.
Throws
InvalidArgumentException
|
public
array
&
|
#
GetValidatorData( array $fieldPropsDefaultValidValues = [] )
Return field specific data for validator.
Return field specific data for validator.
Parameters
- $fieldPropsDefaultValidValues
Returns
array
Overrides
|
public
|
#
PreDispatch( )
This INTERNAL method is called from \MvcCore\Ext\Form just before
field is naturally rendered. It sets up field for rendering process.
Do not use this method event if you don't develop any form field.
- Set up field render mode if not defined.
- Translate label text if necessary.
- Set up tab-index if necessary.
This INTERNAL method is called from \MvcCore\Ext\Form just before
field is naturally rendered. It sets up field for rendering process.
Do not use this method event if you don't develop any form field.
- Set up field render mode if not defined.
- Translate label text if necessary.
- Set up tab-index if necessary.
Overrides
|
public
string
|
#
RenderControl( )
This INTERNAL method is called from \MvcCore\Ext\Forms\Field\Rendering
in rendering process. Do not use this method even if you don't develop any form field.
This INTERNAL method is called from \MvcCore\Ext\Forms\Field\Rendering
in rendering process. Do not use this method even if you don't develop any form field.
Render control tag only without label or specific errors.
Returns
string
Overrides
|
protected
|
#
throwConfigException( integer $errorNumber, $errorMsgArgs = [] )
Throw an configuration exception by given error number.
Throw an configuration exception by given error number.
Parameters
- $errorNumber
- $errorMsgArgs
Throws
InvalidArgumentException
|
Methods inherited from MvcCore\Ext\Forms\IField
AddControlAttrs(),
AddCssClasses(),
AddError(),
AddValidators(),
GetControlAttr(),
GetControlAttrs(),
GetCssClasses(),
GetCssSupportingFile(),
GetId(),
GetJsClassName(),
GetJsSupportingFile(),
GetName(),
GetTemplates(),
GetTitle(),
GetType(),
GetValidators(),
GetValue(),
GetViewScript(),
HasValidator(),
RemoveValidator(),
Render(),
RenderControlInsideLabel(),
RenderErrors(),
RenderLabel(),
RenderLabelAndControl(),
RenderNaturally(),
RenderTemplate(),
SetControlAttr(),
SetControlAttrs(),
SetCssClasses(),
SetCssSupportingFile(),
SetId(),
SetJsClassName(),
SetJsSupportingFile(),
SetName(),
SetTemplate(),
SetTemplates(),
SetTitle(),
SetTranslate(),
SetType(),
SetValidators(),
SetValue(),
SetViewScript()
|
Methods inherited from MvcCore\Ext\Forms\Fields\IVisibleField
GetAccessKey(),
GetAutoFocus(),
GetDisabled(),
GetReadOnly(),
GetRequired(),
GetTabIndex(),
SetAccessKey(),
SetAutoFocus(),
SetDisabled(),
SetReadOnly(),
SetRequired(),
SetTabIndex()
|
Methods inherited from MvcCore\Ext\Forms\Fields\ILabel
AddLabelAttrs(),
GetLabel(),
GetLabelAttr(),
GetLabelAttrs(),
GetLabelSide(),
GetRenderMode(),
SetLabel(),
SetLabelAttr(),
SetLabelAttrs(),
SetLabelSide(),
SetRenderMode()
|
Methods inherited from MvcCore\Ext\Forms\Fields\IFile
AddBombScanners(),
GetAccept(),
GetAllowedFileNameChars(),
GetArchiveMaxCompressPercentage(),
GetArchiveMaxItems(),
GetArchiveMaxLevels(),
GetBombScanners(),
GetCapture(),
GetMaxCount(),
GetMaxSize(),
GetMinCount(),
GetMinSize(),
GetPngImageMaxWidthHeight(),
SetAccept(),
SetAllowedFileNameChars(),
SetArchiveMaxCompressPercentage(),
SetArchiveMaxItems(),
SetArchiveMaxLevels(),
SetBombScanners(),
SetCapture(),
SetMaxCount(),
SetMaxSize(),
SetMinCount(),
SetMinSize(),
SetPngImageMaxWidthHeight()
|
Methods used from MvcCore\Ext\Forms\Field\Props\Label
AddLabelAttrs(),
GetLabel(),
GetLabelAttr(),
GetLabelAttrs(),
GetLabelSide(),
GetRenderMode(),
SetLabel(),
SetLabelAttr(),
SetLabelAttrs(),
SetLabelSide(),
SetRenderMode()
|
Methods used from MvcCore\Ext\Forms\Field\Props\Files
AddBombScanners(),
GetAccept(),
GetAllowedFileNameChars(),
GetArchiveMaxCompressPercentage(),
GetArchiveMaxItems(),
GetArchiveMaxLevels(),
GetBombScanners(),
GetCapture(),
GetMaxCount(),
GetMaxSize(),
GetMinCount(),
GetMinSize(),
GetPngImageMaxWidthHeight(),
SetAccept(),
SetAllowedFileNameChars(),
SetArchiveMaxCompressPercentage(),
SetArchiveMaxItems(),
SetArchiveMaxLevels(),
SetBombScanners(),
SetCapture(),
SetMaxCount(),
SetMaxSize(),
SetMinCount(),
SetMinSize(),
SetPngImageMaxWidthHeight()
|
Methods used from MvcCore\Ext\Forms\Field\Getters
GetControlAttr(),
GetControlAttrs(),
GetCssClasses(),
GetCssSupportingFile(),
GetId(),
GetJsClassName(),
GetJsSupportingFile(),
GetName(),
GetTemplates(),
GetTitle(),
GetTranslate(),
GetType(),
GetValidators(),
GetValue(),
GetViewScript(),
HasValidator()
|
Methods used from MvcCore\Ext\Forms\Field\Setters
AddControlAttrs(),
AddCssClasses(),
AddError(),
AddValidators(),
RemoveValidator(),
SetControlAttr(),
SetControlAttrs(),
SetCssClasses(),
SetCssSupportingFile(),
SetId(),
SetJsClassName(),
SetJsSupportingFile(),
SetName(),
SetTemplate(),
SetTemplates(),
SetTitle(),
SetTranslate(),
SetType(),
SetValidators(),
SetValue(),
SetViewScript()
|
Constants summary
string |
VERSION
MvcCore Extension - Form - Field - File - version:
Comparison by PHP function version_compare();
MvcCore Extension - Form - Field - File - version:
Comparison by PHP function version_compare();
See
http://php.net/manual/en/function.version-compare.php
|
|
string |
ALLOWED_FILE_NAME_CHARS_DEFAULT
Default allowed file name characters and characters groups for submit regular expression.
All regular expression special characters will be escaped by addcslashes()
function to create proper regular expression pattern to keep only characters
and characters groups presented in this constant. This constant is used only
if there is not specified any custom characters and characters groups by method(s):
$field->SetAllowedFileNameChars('...'); or $validator->SetAllowedFileNameChars('...'); .
Default allowed file name characters and characters groups for submit regular expression.
All regular expression special characters will be escaped by addcslashes()
function to create proper regular expression pattern to keep only characters
and characters groups presented in this constant. This constant is used only
if there is not specified any custom characters and characters groups by method(s):
$field->SetAllowedFileNameChars('...'); or $validator->SetAllowedFileNameChars('...'); .
|
#
'-a-zA-Z0-9@,._ ()+={}[]\''
|
integer |
CONFIG_ERR_NO_ACCEPT_PROPERTY
|
|
integer |
CONFIG_ERR_WRONG_FORM_ENCTYPE
|
|
integer |
CONFIG_ERR_UPLOADS_NOT_ALOWED
|
|
integer |
CONFIG_ERR_MAX_UPLOAD_SIZE_LOWER
|
|
integer |
CONFIG_ERR_MAX_POST_SIZE_LOWER
|
|
integer |
CONFIG_ERR_MAX_FILES_COUNT_LOWER
|
|
integer |
CONFIG_ERR_MISMATCH_MIN_MAX_COUNT
|
|
integer |
CONFIG_ERR_MISMATCH_MIN_MAX_SIZE
|
|
Properties summary
protected static
array
|
$configErrorMessages
Configuration error messages.
Configuration error messages.
|
#
[
self::CONFIG_ERR_NO_ACCEPT_PROPERTY => "No `accept` property defined.",
self::CONFIG_ERR_WRONG_FORM_ENCTYPE => "Form needs to define `enctype` attribute as `{0}`.",
self::CONFIG_ERR_UPLOADS_NOT_ALOWED => "System has not allowed file upload.",
self::CONFIG_ERR_MAX_UPLOAD_SIZE_LOWER => "System value for max. file upload size is lower than field configuration.",
self::CONFIG_ERR_MAX_POST_SIZE_LOWER => "System value for max. POST size is lower than field configuration.",
self::CONFIG_ERR_MAX_FILES_COUNT_LOWER => "System value for max. uploaded files count is lower than field configuration.",
self::CONFIG_ERR_MISMATCH_MIN_MAX_COUNT => "Mismatch in min. and max. uploaded files count in field configuration.",
self::CONFIG_ERR_MISMATCH_MIN_MAX_SIZE => "Mismatch in min. and max. uploaded files sizes in field configuration.",
]
|
protected
string
|
$type
|
|
protected
string[]|MvcCore\Ext\Forms\Validator[]
|
$validators
Validators:
- Files - to check everything necessary for uploaded files and check
files by accept attribute rules by magic bytes.
Validators:
- Files - to check everything necessary for uploaded files and check files by accept attribute rules by magic bytes.
|
|
Properties used from MvcCore\Ext\Forms\Field\Props
$controlAttrs,
$cssClasses,
$cssSupportingFile,
$declaredProtectedProperties,
$errors,
$form,
$id,
$jsClassName,
$jsSupportingFile,
$name,
$templates,
$title,
$translate,
$translateTitle,
$value,
$view,
$viewScript
|
Properties used from MvcCore\Ext\Forms\Field\Props\Files
$accept,
$allowedFileNameChars,
$archiveMaxCompressPercentage,
$archiveMaxItems,
$archiveMaxLevels,
$bombScanners,
$capture,
$maxCount,
$maxSize,
$minCount,
$minSize,
$pngImageMaxWidthHeight
|