class FormViewHelper extends AbstractFormViewHelper (View source)

Used to output an HTML

tag which is targeted at the specified action, in the current controller and package.

= Examples =

... ``` ... ... ```
...
... ```
...
``` A form where the value of {customer.name} is automatically inserted inside the textbox; the name of the textbox is set to match the property name.

Properties

protected RenderingContextInterface $renderingContext from  AbstractViewHelper
protected ControllerContext $controllerContext

Controller Context to use

from  AbstractViewHelper
protected ObjectManagerInterface $objectManager from  AbstractViewHelper
protected LoggerInterface $logger from  AbstractViewHelper
protected bool $escapeOutput

Disable escaping of tag based ViewHelpers so that the rendered tag is not htmlspecialchar'd

from  AbstractTagBasedViewHelper
protected TagBuilder $tag

Tag builder instance

from  AbstractTagBasedViewHelper
protected string $tagName
protected PersistenceManagerInterface $persistenceManager from  AbstractFormViewHelper
protected HashService $hashService
protected Context $securityContext
protected MvcPropertyMappingConfigurationService $mvcPropertyMappingConfigurationService
protected AuthenticationManagerInterface $authenticationManager
protected string|null $formActionUri

Methods

void
setRenderingContext(RenderingContextInterface $renderingContext)

No description

void
injectObjectManager(ObjectManagerInterface $objectManager)

No description

void
injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

void
injectTagBuilder(TagBuilder $tag)

No description

void
initialize()

Sets the tag name to $this->tagName.

void
registerTagAttribute(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null)

Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->initializeTag()

void
registerUniversalTagAttributes()

Registers all standard HTML universal attributes.

void
handleAdditionalArguments(array $arguments)

Handles additional arguments, sorting out any data- prefixed tag attributes and assigning them. Then passes the unassigned arguments to the parent class' method, which in the default implementation will throw an error about "undeclared argument used".

void
injectPersistenceManager(PersistenceManagerInterface $persistenceManager)

Injects the Flow Persistence Manager

string
prefixFieldName(string $fieldName)

Prefixes / namespaces the given name with the form field prefix

string
renderHiddenIdentityField(object $object, string $name)

Renders a hidden form field containing the technical identity of the given object.

void
registerFieldNameForFormTokenGeneration(string $fieldName)

Register a field name for inclusion in the HMAC / Form Token generation

void
initializeArguments()

Initialize arguments.

string
render()

Render the form.

string
getFormActionUri()

Returns the action URI of the form tag.

string
renderHiddenActionUriQueryParameters()

Render hidden form fields for query parameters from action URI.

string
renderAdditionalIdentityFields()

Render additional identity fields which were registered by form elements.

string
renderHiddenReferrerFields()

Renders hidden form fields for referrer information about the current controller and action.

void
addFormObjectNameToViewHelperVariableContainer()

Adds the form object name to the ViewHelperVariableContainer if "objectName" argument or "name" attribute is specified.

void
removeFormObjectNameFromViewHelperVariableContainer()

Removes the form object name from the ViewHelperVariableContainer.

string|null
getFormObjectName()

Returns the name of the object that is bound to this form.

void
addFormObjectToViewHelperVariableContainer()

Adds the object that is bound to this form to the ViewHelperVariableContainer if the formObject attribute is specified.

void
removeFormObjectFromViewHelperVariableContainer()

Removes the form object from the ViewHelperVariableContainer.

void
addFieldNamePrefixToViewHelperVariableContainer()

Adds the field name prefix to the ViewHelperVariableContainer

string
getFieldNamePrefix()

Get the field name prefix

string
getDefaultFieldNamePrefix()

Retrieves the default field name prefix for this form

void
removeFieldNamePrefixFromViewHelperVariableContainer()

Removes field name prefix from the ViewHelperVariableContainer

void
addFormFieldNamesToViewHelperVariableContainer()

Adds a container for form field names to the ViewHelperVariableContainer

void
removeFormFieldNamesFromViewHelperVariableContainer()

Removes the container for form field names from the ViewHelperVariableContainer

void
addEmptyHiddenFieldNamesToViewHelperVariableContainer()

Adds a container for rendered hidden field names for empty values to the ViewHelperVariableContainer

void
removeEmptyHiddenFieldNamesFromViewHelperVariableContainer()

Removes container for rendered hidden field names for empty values from ViewHelperVariableContainer

string
renderEmptyHiddenFields()

Renders all empty hidden fields that have been added to ViewHelperVariableContainer

string
renderTrustedPropertiesField()

Render the request hash field

string
renderCsrfTokenField()

Render the a hidden field with a CSRF token

Details

void setRenderingContext(RenderingContextInterface $renderingContext)

No description

Parameters

RenderingContextInterface $renderingContext

Return Value

void

void injectObjectManager(ObjectManagerInterface $objectManager)

No description

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void injectLogger(LoggerInterface $logger)

Injects the (system) logger based on PSR-3.

Parameters

LoggerInterface $logger

Return Value

void

bool isEscapingInterceptorEnabled()

No description

Return Value

bool

__construct()

Constructor

void injectTagBuilder(TagBuilder $tag)

No description

Parameters

TagBuilder $tag

Return Value

void

void initialize()

Sets the tag name to $this->tagName.

Additionally, sets all tag attributes which were registered in $this->tagAttributes and additionalArguments.

Will be invoked just before the render method.

Return Value

void

protected void registerTagAttribute(string $name, string $type, string $description, bool $required = false, mixed $defaultValue = null)

Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->initializeTag()

Parameters

string $name

Name of tag attribute

string $type

Type of the tag attribute

string $description

Description of tag attribute

bool $required

set to true if tag attribute is required. Defaults to false.

mixed $defaultValue

Optional, default value of attribute if one applies

Return Value

void

protected void registerUniversalTagAttributes()

Registers all standard HTML universal attributes.

Should be used inside registerArguments();

Return Value

void

void handleAdditionalArguments(array $arguments)

Handles additional arguments, sorting out any data- prefixed tag attributes and assigning them. Then passes the unassigned arguments to the parent class' method, which in the default implementation will throw an error about "undeclared argument used".

Parameters

array $arguments

Return Value

void

void injectPersistenceManager(PersistenceManagerInterface $persistenceManager)

Injects the Flow Persistence Manager

Parameters

PersistenceManagerInterface $persistenceManager

Return Value

void

protected string prefixFieldName(string $fieldName)

Prefixes / namespaces the given name with the form field prefix

Parameters

string $fieldName

field name to be prefixed

Return Value

string

namespaced field name

protected string renderHiddenIdentityField(object $object, string $name)

Renders a hidden form field containing the technical identity of the given object.

Parameters

object $object

Object to create the identity field for

string $name Name

Return Value

string

A hidden field containing the Identity (UUID in Flow) of the given object or empty string if the object is unknown to the persistence framework

See also

Argument::setValue

protected void registerFieldNameForFormTokenGeneration(string $fieldName)

Register a field name for inclusion in the HMAC / Form Token generation

Parameters

string $fieldName

name of the field to register

Return Value

void

void initializeArguments()

Initialize arguments.

Return Value

void

string render()

Render the form.

Return Value

string

rendered form

Exceptions

Exception

protected string getFormActionUri()

Returns the action URI of the form tag.

If the argument "actionUri" is specified, this will be returned Otherwise this creates the action URI using the UriBuilder

Return Value

string

Exceptions

Exception

protected string renderHiddenActionUriQueryParameters()

Render hidden form fields for query parameters from action URI.

This is only needed if the form method is GET.

Return Value

string

Hidden fields for query parameters from action URI

protected string renderAdditionalIdentityFields()

Render additional identity fields which were registered by form elements.

This happens if a form field is defined like property="bla.blubb" - then we might need an identity property for the sub-object "bla".

Return Value

string

HTML-string for the additional identity properties

protected string renderHiddenReferrerFields()

Renders hidden form fields for referrer information about the current controller and action.

filter out referrer information that is equal to the target (e.g. same packageKey)

Return Value

string

Hidden fields with referrer information

protected void addFormObjectNameToViewHelperVariableContainer()

Adds the form object name to the ViewHelperVariableContainer if "objectName" argument or "name" attribute is specified.

Return Value

void

protected void removeFormObjectNameFromViewHelperVariableContainer()

Removes the form object name from the ViewHelperVariableContainer.

Return Value

void

protected string|null getFormObjectName()

Returns the name of the object that is bound to this form.

If the "objectName" argument has been specified, this is returned. Otherwise the name attribute of this form. If neither objectName nor name arguments have been set, NULL is returned.

Return Value

string|null

specified Form name or NULL if neither $objectName nor $name arguments have been specified

protected void addFormObjectToViewHelperVariableContainer()

Adds the object that is bound to this form to the ViewHelperVariableContainer if the formObject attribute is specified.

Return Value

void

protected void removeFormObjectFromViewHelperVariableContainer()

Removes the form object from the ViewHelperVariableContainer.

Return Value

void

protected void addFieldNamePrefixToViewHelperVariableContainer()

Adds the field name prefix to the ViewHelperVariableContainer

Return Value

void

protected string getFieldNamePrefix()

Get the field name prefix

Return Value

string

protected string getDefaultFieldNamePrefix()

Retrieves the default field name prefix for this form

Return Value

string

default field name prefix

protected void removeFieldNamePrefixFromViewHelperVariableContainer()

Removes field name prefix from the ViewHelperVariableContainer

Return Value

void

protected void addFormFieldNamesToViewHelperVariableContainer()

Adds a container for form field names to the ViewHelperVariableContainer

Return Value

void

protected void removeFormFieldNamesFromViewHelperVariableContainer()

Removes the container for form field names from the ViewHelperVariableContainer

Return Value

void

protected void addEmptyHiddenFieldNamesToViewHelperVariableContainer()

Adds a container for rendered hidden field names for empty values to the ViewHelperVariableContainer

protected void removeEmptyHiddenFieldNamesFromViewHelperVariableContainer()

Removes container for rendered hidden field names for empty values from ViewHelperVariableContainer

protected string renderEmptyHiddenFields()

Renders all empty hidden fields that have been added to ViewHelperVariableContainer

protected string renderTrustedPropertiesField()

Render the request hash field

Return Value

string

the hmac field

protected string renderCsrfTokenField()

Render the a hidden field with a CSRF token

Return Value

string

the CSRF token field