Contao Utils Bundle

FormUtil
in package

Class FormUtil.

Tags
see
https://heimrichhannot.github.io/contao-utils-bundle/HeimrichHannot/UtilsBundle/Form/FormUtil.html

Table of Contents

Properties

$framework  : ContaoFrameworkInterface
$optionsCache  : array<string|int, mixed>
$container  : ContainerInterface

Methods

__construct()  : mixed
escapeAllHtmlEntities()  : mixed
getBackendFormField()  : Widget|null
Get an instance of Widget by passing fieldname and dca data.
getModelDataAsNotificationTokens()  : mixed
getWidgetFromAttributes()  : Widget|null
Get a new widget instance based on given attributes from a Data Container array.
prepareSpecialValueForOutput()  : string
Prepares a special field's value. If an array is inserted, the function will call itself recursively.

Properties

$framework

protected ContaoFrameworkInterface $framework

$optionsCache

protected array<string|int, mixed> $optionsCache

$container

private ContainerInterface $container

Methods

__construct()

public __construct(ContainerInterface $container, ContaoFrameworkInterface $framework) : mixed
Parameters
$container : ContainerInterface
$framework : ContaoFrameworkInterface

escapeAllHtmlEntities()

public escapeAllHtmlEntities(mixed $table, mixed $field, mixed $value) : mixed
Parameters
$table : mixed
$field : mixed
$value : mixed

getBackendFormField()

Get an instance of Widget by passing fieldname and dca data.

public getBackendFormField(string $fieldName, array<string|int, mixed> $dca[, array<string|int, mixed>|null $value = null ][, string $dbField = '' ][, string $table = '' ][, null $dataContainer = null ]) : Widget|null
Parameters
$fieldName : string

The field name

$dca : array<string|int, mixed>

The DCA

$value : array<string|int, mixed>|null = null
$dbField : string = ''

The database field name

$table : string = ''

The table

$dataContainer : null = null

object The data container

Return values
Widget|null

getModelDataAsNotificationTokens()

public getModelDataAsNotificationTokens(array<string|int, mixed> $data, string $prefix, DataContainer $dc[, array<string|int, mixed> $config = [] ]) : mixed
Parameters
$data : array<string|int, mixed>
$prefix : string
$dc : DataContainer
$config : array<string|int, mixed> = []

getWidgetFromAttributes()

Get a new widget instance based on given attributes from a Data Container array.

public getWidgetFromAttributes(string $name, array<string|int, mixed> $data[, mixed $value = null ][, string $dbName = '' ][, string $table = '' ][, DataContainer|null $dc = null ][, string $mode = '' ]) : Widget|null
Parameters
$name : string

The field name in the form

$data : array<string|int, mixed>

The field configuration array

$value : mixed = null

The field value

$dbName : string = ''

The field name in the database

$table : string = ''

The table name in the database

$dc : DataContainer|null = null

An optional DataContainer object

$mode : string = ''

The contao mode, use FE or BE to get proper widget/form type

Return values
Widget|null

The new widget based on given attributes

prepareSpecialValueForOutput()

Prepares a special field's value. If an array is inserted, the function will call itself recursively.

public prepareSpecialValueForOutput(string $field, mixed $value, DataContainer $dc[, array<string|int, mixed> $config = [] ][, bool $isRecursiveCall = false ]) : string

Possible config options:

  • preserveEmptyArrayValues -> preserves array values even if they're empty
  • skipLocalization -> skips usage of "reference" array defined in the field's dca
  • skipDcaLoading: boolean -> skip calling Controller::loadDataContainer on $dc->table
  • skipOptionCaching -> skip caching options if $value is an array
  • _dcaOverride: Array Set a custom dca from outside, which will be used instead of global dca value.
Parameters
$field : string
$value : mixed
$dc : DataContainer
$config : array<string|int, mixed> = []
$isRecursiveCall : bool = false
Return values
string

        
On this page

Search results