FormRuntime implements RootRenderableInterface, ArrayAccess

This class implements the *runtime logic* of a form, i.e. deciding which page is shown currently, what the current values of the form are, trigger validation and property mapping.

You generally receive an instance of this class by calling .

Rendering a Form

That's easy, just call render() on the FormRuntime:

/---code php $form = $formDefinition->bind($request); $renderedForm = $form->render(); ---

Accessing Form Values

In order to get the values the user has entered into the form, you can access this object like an array: If a form field with the identifier firstName exists, you can do $form['firstName'] to retrieve its current value.

You can also set values in the same way.

Rendering Internals

The FormRuntime asks the FormDefinition about the configured Renderer which should be used (), and then trigger render() on this Renderer.

This makes it possible to declaratively define how a form should be rendered.

Scope: frontend This class is NOT meant to be sub classed by developers.

Internal

High cohesion to FormDefinition, may change any time

Tags
todo:

Declare final in v12

Attributes
#[Autoconfigure]
$public: true
$shared: false

Table of Contents

Interfaces

RootRenderableInterface
Base interface which all parts of a form must adhere to.
ArrayAccess

Constants

HONEYPOT_NAME_SESSION_IDENTIFIER  = 'tx_form_honeypot_name_'

Properties

$configurationManager  : ConfigurationManagerInterface
$container  : ContainerInterface
$currentFinisher  : FinisherInterface
Reference to the current running finisher
$currentPage  : Page|null
The current page is the page which will be displayed to the user during rendering.
$currentSiteLanguage  : SiteLanguage
The current site language configuration.
$formDefinition  : FormDefinition
$formSession  : FormSession|null
Individual unique random form session identifier valid for current user session. This value is not persisted server-side.
$formState  : FormState
$hashService  : HashService
$lastDisplayedPage  : Page
Reference to the page which has been shown on the last request (i.e.
$request  : RequestInterface
$response  : ResponseInterface
$validatorResolver  : ValidatorResolver

Methods

__construct()  : mixed
canProcessFormSubmission()  : bool
Only process values if there is a post request and if the surrounding content object is uncached.
getCurrentFinisher()  : FinisherInterface|null
Reference to the current running finisher
getCurrentPage()  : Page|null
Returns the currently selected page
getCurrentSiteLanguage()  : SiteLanguage
Get the current site language configuration.
getElementValue()  : mixed
Returns the value of the specified element
getFormDefinition()  : FormDefinition
Get the underlying form definition from the runtime
getFormSession()  : FormSession|null
getFormState()  : FormState|null
getIdentifier()  : string
The identifier of this renderable
getLabel()  : string
Get the label which shall be displayed next to the form element
getNextEnabledPage()  : Page|null
Returns the next enabled page of the currently selected one or NULL if there is no next page
getNextPage()  : Page|null
Returns the next page of the currently selected one or NULL if there is no next page
getPages()  : array<string|int, mixed>|array<string|int, Page>
getPreviousEnabledPage()  : Page|null
Returns the previous enabled page of the currently selected one or NULL if there is no previous page
getPreviousPage()  : Page|null
Returns the previous page of the currently selected one or NULL if there is no previous page
getRendererClassName()  : string
Get the renderer class name to be used to display this renderable; must implement RendererInterface
getRenderingOptions()  : array<string|int, mixed>
Get all rendering options
getRequest()  : RequestInterface
Get the request this object is bound to.
getResponse()  : ResponseInterface
Get the response this object is bound to.
getTemplateName()  : string
Get the template name of the renderable
getType()  : string
Abstract "type" of this Renderable. Is used during the rendering process to determine the template file or the View PHP class being used to render the particular element.
initialize()  : mixed
offsetExists()  : bool
offsetGet()  : mixed
offsetSet()  : void
offsetUnset()  : void
overrideCurrentPage()  : mixed
Override the current page taken from the request, rendering the page with index $pageIndex instead.
render()  : string|null
Render this form.
setCurrentSiteLanguage()  : void
Override the current site language configuration.
setFormDefinition()  : mixed
setRequest()  : mixed
getConditionResolver()  : Resolver
getFrontendUser()  : FrontendUserAuthentication
getHoneypotNameFromSession()  : string|null
initializeCurrentPageFromRequest()  : mixed
Initializes the current page data based on the current request, also modifiable by a hook
initializeCurrentSiteLanguage()  : void
Initialize the SiteLanguage object.
initializeFormSessionFromRequest()  : void
initializeFormStateFromRequest()  : mixed
Initializes the current state of the form, based on the request
initializeHoneypotFromRequest()  : mixed
Checks if the honey pot is active, and adds a validator if so.
invokeFinishers()  : string
Executes all finishers of this form
isAfterLastPage()  : bool
Returns TRUE if the last page of the form has been submitted, otherwise FALSE
isFirstRequest()  : bool
Returns TRUE if no previous page is stored in the FormState, otherwise FALSE
isFrontendUserAuthenticated()  : bool
Necessary to know if honeypot information should be stored in the user session info, or in the anonymous session.
isPostRequest()  : bool
isRenderableEnabled()  : bool
isRenderedCached()  : bool
Determine whether the surrounding content object is cached.
mapAndValidatePage()  : Result
processSubmittedFormValues()  : mixed
Runs through all validations
processVariants()  : void
renderHoneypot()  : mixed
Renders a hidden field if the honey pot is active.
setHoneypotNameInSession()  : mixed
triggerAfterFormStateInitialized()  : void
userWentBackToPreviousStep()  : bool
returns TRUE if the user went back to any previous step in the form.

Constants

HONEYPOT_NAME_SESSION_IDENTIFIER

public mixed HONEYPOT_NAME_SESSION_IDENTIFIER = 'tx_form_honeypot_name_'

Properties

$container read-only

protected ContainerInterface $container

$currentPage

The current page is the page which will be displayed to the user during rendering.

protected Page|null $currentPage

If $currentPage is NULL, the last page has been submitted and finishing actions need to take place. You should use $this->isAfterLastPage() instead of explicitly checking for NULL.

$currentSiteLanguage

The current site language configuration.

protected SiteLanguage $currentSiteLanguage

$formSession

Individual unique random form session identifier valid for current user session. This value is not persisted server-side.

protected FormSession|null $formSession

$lastDisplayedPage

Reference to the page which has been shown on the last request (i.e.

protected Page $lastDisplayedPage

we have to handle the submitted data from lastDisplayedPage)

$response

protected ResponseInterface $response

Methods

canProcessFormSubmission()

Only process values if there is a post request and if the surrounding content object is uncached.

public canProcessFormSubmission() : bool

Is this not the case, all possible submitted values will be discarded and the first form step will be shown with an empty form state.

Internal
Return values
bool

getCurrentPage()

Returns the currently selected page

public getCurrentPage() : Page|null
Return values
Page|null

getElementValue()

Returns the value of the specified element

public getElementValue(string $identifier) : mixed
Parameters
$identifier : string

getIdentifier()

The identifier of this renderable

public getIdentifier() : string
Return values
string

The identifier of underlying form

getLabel()

Get the label which shall be displayed next to the form element

public getLabel() : string
Return values
string

getNextEnabledPage()

Returns the next enabled page of the currently selected one or NULL if there is no next page

public getNextEnabledPage() : Page|null
Return values
Page|null

getNextPage()

Returns the next page of the currently selected one or NULL if there is no next page

public getNextPage() : Page|null
Return values
Page|null

getPages()

public getPages() : array<string|int, mixed>|array<string|int, Page>
Return values
array<string|int, mixed>|array<string|int, Page>

The Form's pages in the correct order

getPreviousEnabledPage()

Returns the previous enabled page of the currently selected one or NULL if there is no previous page

public getPreviousEnabledPage() : Page|null
Return values
Page|null

getPreviousPage()

Returns the previous page of the currently selected one or NULL if there is no previous page

public getPreviousPage() : Page|null
Return values
Page|null

getRendererClassName()

Get the renderer class name to be used to display this renderable; must implement RendererInterface

public getRendererClassName() : string
Return values
string

the renderer class name

getRenderingOptions()

Get all rendering options

public getRenderingOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

associative array of rendering options

getRequest()

Get the request this object is bound to.

public getRequest() : RequestInterface

This is mostly relevant inside Finishers, where you f.e. want to redirect the user to another page.

Return values
RequestInterface

The request this object is bound to

getResponse()

Get the response this object is bound to.

public getResponse() : ResponseInterface

This is mostly relevant inside Finishers, where you f.e. want to set response headers or output content.

Return values
ResponseInterface

the response this object is bound to

getTemplateName()

Get the template name of the renderable

public getTemplateName() : string
Return values
string

getType()

Abstract "type" of this Renderable. Is used during the rendering process to determine the template file or the View PHP class being used to render the particular element.

public getType() : string
Return values
string

offsetExists()

public offsetExists(string $identifier) : bool
Parameters
$identifier : string
Internal
Return values
bool

offsetGet()

public offsetGet(string $identifier) : mixed
Parameters
$identifier : string
Internal

offsetSet()

public offsetSet(string $identifier, mixed $value) : void
Parameters
$identifier : string
$value : mixed
Internal

offsetUnset()

public offsetUnset(string $identifier) : void
Parameters
$identifier : string
Internal

overrideCurrentPage()

Override the current page taken from the request, rendering the page with index $pageIndex instead.

public overrideCurrentPage(int $pageIndex) : mixed

This is typically not needed in production code, but it is very helpful when displaying some kind of "preview" of the form (e.g. form editor).

Parameters
$pageIndex : int

setCurrentSiteLanguage()

Override the current site language configuration.

public setCurrentSiteLanguage(SiteLanguage $currentSiteLanguage) : void

This is typically not needed in production code, but it is very helpful when displaying some kind of "preview" of the form (e.g. form editor).

Parameters
$currentSiteLanguage : SiteLanguage

getHoneypotNameFromSession()

protected getHoneypotNameFromSession(Page $page) : string|null
Parameters
$page : Page
Return values
string|null

initializeCurrentPageFromRequest()

Initializes the current page data based on the current request, also modifiable by a hook

protected initializeCurrentPageFromRequest() : mixed

initializeCurrentSiteLanguage()

Initialize the SiteLanguage object.

protected initializeCurrentSiteLanguage() : void

This is mainly used by the condition matcher.

initializeFormSessionFromRequest()

protected initializeFormSessionFromRequest() : void
Tags
todo

FormRuntime::$formSession is still vulnerable to session fixation unless a real cookie-based process is used

initializeFormStateFromRequest()

Initializes the current state of the form, based on the request

protected initializeFormStateFromRequest() : mixed
Tags
throws
BadRequestException

initializeHoneypotFromRequest()

Checks if the honey pot is active, and adds a validator if so.

protected initializeHoneypotFromRequest() : mixed

invokeFinishers()

Executes all finishers of this form

protected invokeFinishers() : string
Return values
string

isAfterLastPage()

Returns TRUE if the last page of the form has been submitted, otherwise FALSE

protected isAfterLastPage() : bool
Return values
bool

isFirstRequest()

Returns TRUE if no previous page is stored in the FormState, otherwise FALSE

protected isFirstRequest() : bool
Return values
bool

isFrontendUserAuthenticated()

Necessary to know if honeypot information should be stored in the user session info, or in the anonymous session.

protected isFrontendUserAuthenticated() : bool
Return values
bool

isPostRequest()

protected isPostRequest() : bool
Return values
bool

isRenderedCached()

Determine whether the surrounding content object is cached.

protected isRenderedCached() : bool

If no surrounding content object can be found (which would be strange) we assume a cached request for safety which means that an empty form will be rendered.

Return values
bool

processSubmittedFormValues()

Runs through all validations

protected processSubmittedFormValues() : mixed

processVariants()

protected processVariants() : void

renderHoneypot()

Renders a hidden field if the honey pot is active.

protected renderHoneypot() : mixed

setHoneypotNameInSession()

protected setHoneypotNameInSession(Page $page, string $honeypotName) : mixed
Parameters
$page : Page
$honeypotName : string

triggerAfterFormStateInitialized()

protected triggerAfterFormStateInitialized() : void

userWentBackToPreviousStep()

returns TRUE if the user went back to any previous step in the form.

protected userWentBackToPreviousStep() : bool
Return values
bool

        
On this page

Search results