Documentation

FormGenerator
in package

Table of Contents

Properties

$formIncrement  : int
$componentOptions  : array<string|int, mixed>
$entity  : mixed
$entityClass  : string
$form  : FormElement
$formId  : int
$noView  : bool
$options  : array<string|int, mixed>
$viewGenerator  : ViewGenerator

Methods

__construct()  : mixed
FormGenerator constructor.
__toString()  : mixed
findEntityByIndexData()  : EntityBase
Finds an entity by its index data
getData()  : mixed
getDataElement()  : DataElement
This function returns the DataElement
getDataElementGroup()  : HtmlElement
This function returns the elementGroup for a DataElement
getDataElementWithoutType()  : DataElement
Return a DataElement without previously defining the type.
getEntity()  : mixed
getEntityIndexData()  : array<string|int, mixed>
Helper function to get a list of all values of identifier fields
getForm()  : mixed
getId()  : mixed
isValid()  : mixed
render()  : mixed
constructView()  : mixed
Generate a view with a form.
createCssClassNameFromEntity()  : string
This method returns a css valid name for a given php class
getDataElementValueAsString()  : string
This function returns the value of a passed object/array/element as a string according to the type At the moment only date and time formats are supported
getForeignEntitySelectOptionData()  : array<string|int, mixed>
Returns the data needed to create a n:x multiselect
getFormLabel()  : mixed
getIdentifyingDisplayValue()  : array<string|int, mixed>
This function returns the HtmlElements to display for 1:n relations

Properties

$formIncrement

public static int $formIncrement = 0

This ID is used to store the next free $formId

$componentOptions

protected array<string|int, mixed> $componentOptions

component options

$formId

protected int $formId

This ID is used as html id for the form so we can load more than one form

Methods

__construct()

FormGenerator constructor.

public __construct(array<string|int, mixed> $entity[, null $actionUrl = null ][, string $entityClass = '' ][, string $title = '' ][, array<string|int, mixed> $options = array() ][, int $entityId = 0 ][, mixed $componentOptions = null ][, Controller $viewGenerator = null ][, bool $noView = false ]) : mixed
Parameters
$entity : array<string|int, mixed>

entity to display

$actionUrl : null = null

action url

$entityClass : string = ''

entity class name

$title : string = ''

title for view

$options : array<string|int, mixed> = array()

options from ViewGenerator

$entityId : int = 0

id of a specific entity

$componentOptions : mixed = null

options of the component

$viewGenerator : Controller = null

instance of ViewGenerator

$noView : bool = false

to set if a view should be created

findEntityByIndexData()

Finds an entity by its index data

public static findEntityByIndexData(string $entityClass, array<string|int, mixed> $indexData) : EntityBase
Parameters
$entityClass : string

Fully qualified class name

$indexData : array<string|int, mixed>

List of index values

Return values
EntityBase

The matching entity (or null)

getDataElement()

This function returns the DataElement

public getDataElement(string $name, string $title, string $type, int $length, mixed $value, array<string|int, mixed> &$options, int $entityId, array<string|int, mixed> $entityData) : DataElement
Parameters
$name : string

name of the DataElement

$title : string

used title instead of name if html tag should not be called like the attribute

$type : string

type of the DataElement

$length : int

length of the DataElement

$value : mixed

value of the DataElement

$options : array<string|int, mixed>

options for the DataElement

$entityId : int

id of the DataElement

$entityData : array<string|int, mixed>

Data of the current entity

Tags
todo

Return type is inconsistent. Needs to be DataElement always!

todo

Return type can be null, should this throw an exception instead?

Return values
DataElement

getDataElementGroup()

This function returns the elementGroup for a DataElement

public getDataElementGroup(string $field, object $dataElement[, array<string|int, mixed> $fieldOptions = array() ]) : HtmlElement
Parameters
$field : string

name of the field

$dataElement : object

the element of the field

$fieldOptions : array<string|int, mixed> = array()

options for the field

Return values
HtmlElement

getDataElementWithoutType()

Return a DataElement without previously defining the type.

public getDataElementWithoutType(string $name, string $title, int $length, mixed $value, int $entityId, array<string|int, mixed> $entityData) : DataElement
Parameters
$name : string

name of the DataElement

$title : string

used title instead of name if html tag should not be called like the attribute

$length : int

length of the DataElement

$value : mixed

value of the DataElement

$entityId : int

id of the DataElement

$entityData : array<string|int, mixed>

Data of the current entity

Tags
todo

Return type can be null, should this throw an exception instead?

Return values
DataElement

getEntityIndexData()

Helper function to get a list of all values of identifier fields

public static getEntityIndexData(EntityBase $entity) : array<string|int, mixed>
Parameters
$entity : EntityBase

Entity to get index data of

Return values
array<string|int, mixed>

List of values

constructView()

Generate a view with a form.

protected constructView(array<string|int, mixed> $entity, null $actionUrl, string $entityClass, string $title, array<string|int, mixed> $options, int $entityId) : mixed
Parameters
$entity : array<string|int, mixed>

entity to display

$actionUrl : null

action url

$entityClass : string

entity class name

$title : string

title for view

$options : array<string|int, mixed>

options from ViewGenerator

$entityId : int

id of a specific entity

createCssClassNameFromEntity()

This method returns a css valid name for a given php class

protected createCssClassNameFromEntity(string $entityClass) : string
Parameters
$entityClass : string

class including namespace

Tags
access

protected

Return values
string

css class

getDataElementValueAsString()

This function returns the value of a passed object/array/element as a string according to the type At the moment only date and time formats are supported

protected getDataElementValueAsString(mixed $element) : string
Parameters
$element : mixed

element of which we want to create a string

Tags
access

protected

Return values
string

value of DataElement as string

getForeignEntitySelectOptionData()

Returns the data needed to create a n:x multiselect

protected getForeignEntitySelectOptionData(array<string|int, mixed> $assocMapping, string $entityClass, int $entityId, arrray $options) : array<string|int, mixed>

This returns an array with two indexes, each containig an array in the following form: array(<entityIndexData> => ). Entity index data is a string of all all identifier field values joined by "/". The two main keys are "all" and "selected". "all" contains all "foreign" entities, "selected" only the ones selected by the current entity.

Parameters
$assocMapping : array<string|int, mixed>

Mapping information for this relation

$entityClass : string

FQCN of the foreign entity

$entityId : int

ID of the local entity

$options : arrray

Options for this view

Return values
array<string|int, mixed>

Array with two indexes, see method description

getFormLabel()

protected static getFormLabel(mixed $fieldOptions, mixed $key) : mixed
Parameters
$fieldOptions : mixed
$key : mixed

getIdentifyingDisplayValue()

This function returns the HtmlElements to display for 1:n relations

protected getIdentifyingDisplayValue(array<string|int, mixed> $assocMapping, string $entityClass, int $entityId, arrray $options) : array<string|int, mixed>
Parameters
$assocMapping : array<string|int, mixed>

Mapping information for this relation

$entityClass : string

FQCN of the foreign entity

$entityId : int

ID of the local entity

$options : arrray

Options for this view

Tags
todo

this only works with single valued identifiers

Return values
array<string|int, mixed>

Set of \Cx\Core\Html\Model\Entity\HtmlElement instances


        
On this page

Search results