CodeEditorElement extends AbstractFormElement
CodeEditor FormEngine widget
Table of Contents
Properties
- $data : array<string|int, mixed>
- Main data array to work on, given from parent to child elements
- $defaultFieldControl : array<string|int, mixed>
- A list of default field controls added to the element / container.
- $defaultFieldInformation : array<string|int, mixed>
- Default field information enabled for this element.
- $defaultFieldWizard : array<string|int, mixed>
- Default field wizards enabled for this element.
- $defaultInputWidth : int
- Default width value for a couple of elements like text
- $maxInputWidth : int
- Maximum width value for a couple of elements like text
- $minimumInputWidth : int
- Minimum width value for a couple of elements like text
- $mode : string
- $nodeFactory : NodeFactory
- $resultArray : array<string|int, mixed>
Methods
- injectNodeFactory() : void
- Injection of NodeFactory, which is used in this abstract already.
- render() : array<string|int, mixed>
- Render code editor element
- setData() : void
- Retrieve the current data array from NodeFactory.
- appendValueToLabelInDebugMode() : string
- Append the value of a form field to its label
- calculateColumnMarkup() : array<string|int, mixed>
- Calculates the bootstrap grid classes based on the amount of columns defined in the checkbox item TCA
- checkBoxParams() : string
- Creates checkbox parameters
- formatValue() : string
- Format field content if 'format' is set to date, filesize, ..., user
- formMaxWidth() : int
- Returns the max width in pixels for an elements like input and text
-
forwardOnFieldChangeQueryParams()
: array{fieldChangeFunc: array
, fieldChangeFuncHash: string} - Forwards URL query params for `LinkBrowserController`
- getBackendUser() : BackendUserAuthentication
- getHTMLCodeForEditor() : string
- Generates HTML with code editor
- getLanguageService() : LanguageService
- getMode() : Mode
- getOnFieldChangeAttrs() : array<string, string>
- getOnFieldChangeItems() : array<int, array<string|int, mixed>>
- getValidationDataAsJsonString() : string
- Build JSON string for validations rules.
- hasNullCheckboxButNoPlaceholder() : bool
- Returns true if the "null value" checkbox should be rendered. This is used in some "text" based types like "text" and "input" for some renderType's.
- hasNullCheckboxWithPlaceholder() : bool
- Returns true if the "null value" checkbox should be rendered and the placeholder handling is enabled. This is used in some "text" based types like "text" and "input" for some renderType's.
- initializeResultArray() : array<string|int, mixed>
- Initialize the array that is returned to parent after calling. This structure is identical for *all* nodes. Parent will merge the return of a child with its own stuff and in itself return an array of the same structure.
- mergeChildReturnIntoExistingResult() : array<string|int, mixed>
- Merge existing data with a child return array.
- renderFieldControl() : array<string|int, mixed>
- Merge field control configuration with default controls and render them.
- renderFieldInformation() : array<string|int, mixed>
- Merge field information configuration with default and render them.
- renderFieldWizard() : array<string|int, mixed>
- Merge field wizard configuration with default wizards and render them.
- renderLabel() : string
- Render a label element for the current field by given id.
- resolveJavaScriptEvaluation() : array<string|int, mixed>
- Handle custom javascript `eval` implementations. $evalObject is a hook object for custom eval's. It is transferred to JS as a JavaScriptModuleInstruction if possible.
- wrapWithFieldsetAndLegend() : string
- Elements that don't render a simple input field can't have a '<label for="..."'.
Properties
$data
Main data array to work on, given from parent to child elements
protected
array<string|int, mixed>
$data
= []
$defaultFieldControl
A list of default field controls added to the element / container.
protected
array<string|int, mixed>
$defaultFieldControl
= []
This property is often reset by single elements.
$defaultFieldInformation
Default field information enabled for this element.
protected
array<string|int, mixed>
$defaultFieldInformation
= ['tcaDescription' => ['renderType' => 'tcaDescription']]
$defaultFieldWizard
Default field wizards enabled for this element.
protected
array<string|int, mixed>
$defaultFieldWizard
= ['localizationStateSelector' => ['renderType' => 'localizationStateSelector'], 'otherLanguageContent' => ['renderType' => 'otherLanguageContent', 'after' => ['localizationStateSelector']], 'defaultLanguageDifferences' => ['renderType' => 'defaultLanguageDifferences', 'after' => ['otherLanguageContent']]]
$defaultInputWidth
Default width value for a couple of elements like text
protected
int
$defaultInputWidth
= 30
$maxInputWidth
Maximum width value for a couple of elements like text
protected
int
$maxInputWidth
= 50
$minimumInputWidth
Minimum width value for a couple of elements like text
protected
int
$minimumInputWidth
= 10
$mode
protected
string
$mode
= ''
$nodeFactory
protected
NodeFactory
$nodeFactory
$resultArray
protected
array<string|int, mixed>
$resultArray
= []
Methods
injectNodeFactory()
Injection of NodeFactory, which is used in this abstract already.
public
injectNodeFactory(NodeFactory $nodeFactory) : void
Using inject* method to not pollute __construct() for inheriting classes.
Parameters
- $nodeFactory : NodeFactory
render()
Render code editor element
public
render() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —As defined in initializeResultArray() of AbstractNode
setData()
Retrieve the current data array from NodeFactory.
public
setData(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
appendValueToLabelInDebugMode()
Append the value of a form field to its label
protected
appendValueToLabelInDebugMode(string|int $label, string|int $value) : string
Parameters
- $label : string|int
- $value : string|int
Return values
stringcalculateColumnMarkup()
Calculates the bootstrap grid classes based on the amount of columns defined in the checkbox item TCA
protected
calculateColumnMarkup(int $cols) : array<string|int, mixed>
Parameters
- $cols : int
Return values
array<string|int, mixed>checkBoxParams()
Creates checkbox parameters
protected
checkBoxParams(string $itemName, int $formElementValue, int $checkbox, int $checkboxesCount[, array<string|int, mixed> $fieldChangeFuncs = [] ][, bool $invert = false ]) : string
Parameters
- $itemName : string
-
Form element name
- $formElementValue : int
-
The value of the checkbox (representing checkboxes with the bits)
- $checkbox : int
-
Checkbox # (0-9?)
- $checkboxesCount : int
-
Total number of checkboxes in the array.
- $fieldChangeFuncs : array<string|int, mixed> = []
-
fieldChangeFunc
items for client-side handling - $invert : bool = false
-
Inverts the state of the checkbox (but not of the bit value)
Return values
string —either onclick
attr or data-formengine-field-change-*
attrs + possibly the checked-option set
formatValue()
Format field content if 'format' is set to date, filesize, ..., user
protected
formatValue(string $format, string $itemValue[, array<string|int, mixed> $formatOptions = [] ]) : string
Parameters
- $format : string
-
Configuration for the display.
- $itemValue : string
-
The value to display
- $formatOptions : array<string|int, mixed> = []
-
Format options
Return values
string —Formatted field value
formMaxWidth()
Returns the max width in pixels for an elements like input and text
protected
formMaxWidth([int $size = 48 ]) : int
Parameters
- $size : int = 48
-
The abstract size value (1-48)
Return values
int —Maximum width in pixels
forwardOnFieldChangeQueryParams()
Forwards URL query params for `LinkBrowserController`
protected
forwardOnFieldChangeQueryParams(array<int, OnFieldChangeInterface> $items) : array{fieldChangeFunc: array, fieldChangeFuncHash: string}
Parameters
- $items : array<int, OnFieldChangeInterface>
-
fieldChangeFunc
items
Return values
array{fieldChangeFunc: arrayrelevant URL query params for LinkBrowserController
getBackendUser()
protected
getBackendUser() : BackendUserAuthentication
Return values
BackendUserAuthenticationgetHTMLCodeForEditor()
Generates HTML with code editor
protected
getHTMLCodeForEditor(string $name[, string $class = '' ][, string $content = '' ][, array<string|int, mixed> $attributes = [] ][, array<string|int, mixed> $settings = [] ][, array<string|int, mixed> $hiddenfields = [] ]) : string
Parameters
- $name : string
-
Name attribute of HTML tag
- $class : string = ''
-
Class attribute of HTML tag
- $content : string = ''
-
Content of the editor
- $attributes : array<string|int, mixed> = []
-
Any additional editor parameters
- $settings : array<string|int, mixed> = []
- $hiddenfields : array<string|int, mixed> = []
Tags
Return values
string —Generated HTML code for editor
getLanguageService()
protected
getLanguageService() : LanguageService
Return values
LanguageServicegetMode()
protected
getMode() : Mode
Tags
Return values
ModegetOnFieldChangeAttrs()
protected
getOnFieldChangeAttrs(string $event, array<int, OnFieldChangeInterface> $items) : array<string, string>
Parameters
- $event : string
-
target client event, either
change
orclick
- $items : array<int, OnFieldChangeInterface>
-
fieldChangeFunc
items
Return values
array<string, string> —HTML attrs, not encoded - consumers MUST encode with htmlspecialchars
getOnFieldChangeItems()
protected
getOnFieldChangeItems(array<int, OnFieldChangeInterface> $items) : array<int, array<string|int, mixed>>
Parameters
- $items : array<int, OnFieldChangeInterface>
-
fieldChangeFunc
items
Return values
array<int, array<string|int, mixed>>getValidationDataAsJsonString()
Build JSON string for validations rules.
protected
getValidationDataAsJsonString(array<string|int, mixed> $config) : string
Parameters
- $config : array<string|int, mixed>
Return values
stringhasNullCheckboxButNoPlaceholder()
Returns true if the "null value" checkbox should be rendered. This is used in some "text" based types like "text" and "input" for some renderType's.
protected
hasNullCheckboxButNoPlaceholder() : bool
A field has eval=null set, but has no useOverridePlaceholder defined. Goal is to have a field that can distinct between NULL and empty string in the database. A checkbox and an additional hidden field will be created, both with the same name and prefixed with "control[active]". If the checkbox is set (value 1), the value from the casual input field will be written to the database. If the checkbox is not set, the hidden field transfers value=0 to DataHandler, the value of the input field will then be reset to NULL by the DataHandler at an early point in processing, so NULL will be written to DB as field value.
All that only works if the field is not within flex form scope since flex forms can not store a "null" value or distinct it from "empty string".
Return values
boolhasNullCheckboxWithPlaceholder()
Returns true if the "null value" checkbox should be rendered and the placeholder handling is enabled. This is used in some "text" based types like "text" and "input" for some renderType's.
protected
hasNullCheckboxWithPlaceholder() : bool
A field has useOverridePlaceholder set and null in eval and is not within a flex form. Here, a value from a deeper DB structure can be "fetched up" as value, and can also be overridden by a local value. This is used in FAL, where eg. the "title" field can have the default value from sys_file_metadata, the title field of sys_file_reference is then set to NULL. Or the "override" checkbox is set, and a string or an empty string is then written to the field of sys_file_reference. The situation is similar to hasNullCheckboxButNoPlaceholder(), but additionally a "default" value should be shown. To achieve this, again a hidden control[hidden] field is added together with a checkbox with the same name to transfer the information whether the default value should be used or not: Checkbox checked transfers 1 as value in control[active], meaning the overridden value should be used. Additionally to the casual input field, a second field is added containing the "placeholder" value. This field has no name attribute and is not transferred at all. Those two are then hidden / shown depending on the state of the above checkbox in via JS.
Return values
boolinitializeResultArray()
Initialize the array that is returned to parent after calling. This structure is identical for *all* nodes. Parent will merge the return of a child with its own stuff and in itself return an array of the same structure.
protected
initializeResultArray() : array<string|int, mixed>
Return values
array<string|int, mixed>mergeChildReturnIntoExistingResult()
Merge existing data with a child return array.
protected
mergeChildReturnIntoExistingResult(array<string|int, mixed> $existing, array<string|int, mixed> $childReturn[, bool $mergeHtml = true ]) : array<string|int, mixed>
The incoming $childReturn array should be initialized using initializeResultArray() beforehand.
Parameters
- $existing : array<string|int, mixed>
-
Currently merged array
- $childReturn : array<string|int, mixed>
-
Array returned by child
- $mergeHtml : bool = true
-
If false, the ['html'] section of $childReturn will NOT be added to $existing
Return values
array<string|int, mixed> —Result array
renderFieldControl()
Merge field control configuration with default controls and render them.
protected
renderFieldControl() : array<string|int, mixed>
Return values
array<string|int, mixed> —Result array
renderFieldInformation()
Merge field information configuration with default and render them.
protected
renderFieldInformation() : array<string|int, mixed>
Return values
array<string|int, mixed> —Result array
renderFieldWizard()
Merge field wizard configuration with default wizards and render them.
protected
renderFieldWizard() : array<string|int, mixed>
Return values
array<string|int, mixed> —Result array
renderLabel()
Render a label element for the current field by given id.
protected
renderLabel(string $for) : string
Parameters
- $for : string
Return values
stringresolveJavaScriptEvaluation()
Handle custom javascript `eval` implementations. $evalObject is a hook object for custom eval's. It is transferred to JS as a JavaScriptModuleInstruction if possible.
protected
resolveJavaScriptEvaluation(array<string|int, mixed> $resultArray, string $name, object|null $evalObject) : array<string|int, mixed>
This is used by a couple of renderType's like various type="input", should be used with care and is internal for now.
Parameters
- $resultArray : array<string|int, mixed>
- $name : string
- $evalObject : object|null
Return values
array<string|int, mixed>wrapWithFieldsetAndLegend()
Elements that don't render a simple input field can't have a '<label for="..."'.
protected
wrapWithFieldsetAndLegend(string $innerHTML) : string
A fieldset with a legend is used instead.
Parameters
- $innerHTML : string