Fr3nch13/CakePHP Utilities

FileWidget extends BasicWidget
in package

Input widget class for generating a file upload control.

This class is usually used internally by Cake\View\Helper\FormHelper, it but can be used to generate standalone file upload controls.

Table of Contents

Properties

$_templates  : StringTemplate
StringTemplate instance.
$defaults  : array<string, mixed>
Data defaults.

Methods

__construct()  : mixed
Constructor.
render()  : string
Render a file upload form widget.
secureFields()  : array<string|int, string>
Returns a list of fields that need to be secured for this widget.
mergeDefaults()  : array<string, mixed>
Merge default values with supplied data.
setMaxLength()  : array<string, mixed>
Set value for "maxlength" attribute if applicable.
setRequired()  : array<string, mixed>
Set value for "required" attribute if applicable.
setStep()  : array<string, mixed>
Set value for "step" attribute if applicable.

Properties

$defaults

Data defaults.

protected array<string, mixed> $defaults = ['name' => '', 'escape' => true, 'templateVars' => []]

Methods

render()

Render a file upload form widget.

public render(array<string, mixed> $data, ContextInterface $context) : string

Data supports the following keys:

  • name - Set the input name.
  • escape - Set to false to disable HTML escaping.

All other keys will be converted into HTML attributes. Unlike other input objects the val property will be specifically ignored.

Parameters
$data : array<string, mixed>

The data to build a file input with.

$context : ContextInterface

The current form context.

Return values
string

HTML elements.

secureFields()

Returns a list of fields that need to be secured for this widget.

public secureFields(array<string|int, mixed> $data) : array<string|int, string>
Parameters
$data : array<string|int, mixed>

The data to render.

Tags
inheritDoc
Return values
array<string|int, string>

Array of fields to secure.

mergeDefaults()

Merge default values with supplied data.

protected mergeDefaults(array<string, mixed> $data, ContextInterface $context) : array<string, mixed>
Parameters
$data : array<string, mixed>

Data array

$context : ContextInterface

Context instance.

Return values
array<string, mixed>

Updated data array.

setMaxLength()

Set value for "maxlength" attribute if applicable.

protected setMaxLength(array<string, mixed> $data, ContextInterface $context, string $fieldName) : array<string, mixed>
Parameters
$data : array<string, mixed>

Data array

$context : ContextInterface

Context instance.

$fieldName : string

Field name.

Return values
array<string, mixed>

Updated data array.

setRequired()

Set value for "required" attribute if applicable.

protected setRequired(array<string, mixed> $data, ContextInterface $context, string $fieldName) : array<string, mixed>
Parameters
$data : array<string, mixed>

Data array

$context : ContextInterface

Context instance.

$fieldName : string

Field name.

Return values
array<string, mixed>

Updated data array.

setStep()

Set value for "step" attribute if applicable.

protected setStep(array<string, mixed> $data, ContextInterface $context, string $fieldName) : array<string, mixed>
Parameters
$data : array<string, mixed>

Data array

$context : ContextInterface

Context instance.

$fieldName : string

Field name.

Return values
array<string, mixed>

Updated data array.


        
On this page

Search results