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.
High cohesion to FormDefinition, may change any time
Tags
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
- getTypoScriptFrontendController() : TypoScriptFrontendController|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() : mixed
- 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
$configurationManager read-only
protected
ConfigurationManagerInterface
$configurationManager
$container read-only
protected
ContainerInterface
$container
$currentFinisher
Reference to the current running finisher
protected
FinisherInterface
$currentFinisher
$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
$formDefinition
protected
FormDefinition
$formDefinition
$formSession
Individual unique random form session identifier valid for current user session. This value is not persisted server-side.
protected
FormSession|null
$formSession
$formState
protected
FormState
$formState
$hashService read-only
protected
HashService
$hashService
$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)
$request
protected
RequestInterface
$request
$response
protected
ResponseInterface
$response
$validatorResolver read-only
protected
ValidatorResolver
$validatorResolver
Methods
__construct()
public
__construct(ContainerInterface $container, ConfigurationManagerInterface $configurationManager, HashService $hashService, ValidatorResolver $validatorResolver) : mixed
Parameters
- $container : ContainerInterface
- $configurationManager : ConfigurationManagerInterface
- $hashService : HashService
- $validatorResolver : ValidatorResolver
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.
Return values
boolgetCurrentFinisher()
Reference to the current running finisher
public
getCurrentFinisher() : FinisherInterface|null
Return values
FinisherInterface|nullgetCurrentPage()
Returns the currently selected page
public
getCurrentPage() : Page|null
Return values
Page|nullgetCurrentSiteLanguage()
Get the current site language configuration.
public
getCurrentSiteLanguage() : SiteLanguage
Return values
SiteLanguagegetElementValue()
Returns the value of the specified element
public
getElementValue(string $identifier) : mixed
Parameters
- $identifier : string
getFormDefinition()
Get the underlying form definition from the runtime
public
getFormDefinition() : FormDefinition
Return values
FormDefinitiongetFormSession()
public
getFormSession() : FormSession|null
Return values
FormSession|nullgetFormState()
public
getFormState() : FormState|null
Return values
FormState|nullgetIdentifier()
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
stringgetNextEnabledPage()
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|nullgetNextPage()
Returns the next page of the currently selected one or NULL if there is no next page
public
getNextPage() : Page|null
Return values
Page|nullgetPages()
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|nullgetPreviousPage()
Returns the previous page of the currently selected one or NULL if there is no previous page
public
getPreviousPage() : Page|null
Return values
Page|nullgetRendererClassName()
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
stringgetType()
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
stringinitialize()
public
initialize() : mixed
offsetExists()
public
offsetExists(string $identifier) : bool
Parameters
- $identifier : string
Return values
booloffsetGet()
public
offsetGet(string $identifier) : mixed
Parameters
- $identifier : string
offsetSet()
public
offsetSet(string $identifier, mixed $value) : void
Parameters
- $identifier : string
- $value : mixed
offsetUnset()
public
offsetUnset(string $identifier) : void
Parameters
- $identifier : string
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
render()
Render this form.
public
render() : string|null
Tags
Return values
string|null —rendered form
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
setFormDefinition()
public
setFormDefinition(FormDefinition $formDefinition) : mixed
Parameters
- $formDefinition : FormDefinition
setRequest()
public
setRequest(RequestInterface $request) : mixed
Parameters
- $request : RequestInterface
getConditionResolver()
protected
getConditionResolver() : Resolver
Return values
ResolvergetFrontendUser()
protected
getFrontendUser() : FrontendUserAuthentication
Return values
FrontendUserAuthenticationgetHoneypotNameFromSession()
protected
getHoneypotNameFromSession(Page $page) : string|null
Parameters
- $page : Page
Return values
string|nullgetTypoScriptFrontendController()
protected
getTypoScriptFrontendController() : TypoScriptFrontendController|null
Return values
TypoScriptFrontendController|nullinitializeCurrentPageFromRequest()
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
initializeFormStateFromRequest()
Initializes the current state of the form, based on the request
protected
initializeFormStateFromRequest() : mixed
Tags
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
stringisAfterLastPage()
Returns TRUE if the last page of the form has been submitted, otherwise FALSE
protected
isAfterLastPage() : bool
Return values
boolisFirstRequest()
Returns TRUE if no previous page is stored in the FormState, otherwise FALSE
protected
isFirstRequest() : bool
Return values
boolisFrontendUserAuthenticated()
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 —true when a frontend user is logged, otherwise false
isPostRequest()
protected
isPostRequest() : bool
Return values
boolisRenderableEnabled()
protected
isRenderableEnabled(RenderableInterface $renderable) : bool
Parameters
- $renderable : RenderableInterface
Return values
boolisRenderedCached()
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
boolmapAndValidatePage()
protected
mapAndValidatePage(Page $page) : Result
Parameters
- $page : Page
Tags
Return values
ResultprocessSubmittedFormValues()
Runs through all validations
protected
processSubmittedFormValues() : mixed
processVariants()
protected
processVariants() : mixed
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