TextareaWidget
extends BasicWidget
in package
Input widget class for generating a textarea control.
This class is usually used internally by Cake\View\Helper\FormHelper
,
it but can be used to generate standalone text areas.
Table of Contents
Properties
- $_templates : StringTemplate
- StringTemplate instance.
- $defaults : array<string, mixed>
- Data defaults.
Methods
- __construct() : mixed
- Constructor.
- render() : string
- Render a text area 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
$_templates
StringTemplate instance.
protected
StringTemplate
$_templates
$defaults
Data defaults.
protected
array<string, mixed>
$defaults
= ['val' => '', 'name' => '', 'escape' => true, 'rows' => 5, 'templateVars' => []]
Methods
__construct()
Constructor.
public
__construct(StringTemplate $templates) : mixed
Parameters
- $templates : StringTemplate
-
Templates list.
render()
Render a text area form widget.
public
render(array<string, mixed> $data, ContextInterface $context) : string
Data supports the following keys:
-
name
- Set the input name. -
val
- A string of the option to mark as selected. -
escape
- Set to false to disable HTML escaping.
All other keys will be converted into HTML attributes.
Parameters
- $data : array<string, mixed>
-
The data to build a textarea 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
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.