Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Form ViewHelper <f:form>
Form ViewHelper. Generates a <form>
Tag.
Basic usage
Use <f:
to output an HTML <form>
tag which is targeted
at the specified action, in the current controller and package.
It will submit the form data via a POST request. If you want to change this,
use method="get"
as an argument.
Examples
A complex form with a specified encoding type
Form with enctype set:
<f:form action=".." controller="..." package="..." enctype="multipart/form-data">...</f:form>
A Form which should render a domain object
Binding a domain object to a form:
<f:form action="..." name="customer" object="{customer}">
<f:form.hidden property="id" />
<f:form.textarea property="name" />
</f:form>
This automatically inserts the value of {customer.name}
inside the
textarea and adjusts the name of the textarea accordingly.
Source code
Go to the source code of this ViewHelper: FormViewHelper.php (GitHub).
Arguments
The following arguments are available for <f:
:
additionalAttributes
-
- Type
- mixed
Additional tag attributes. They will be added directly to the resulting HTML tag.
data
-
- Type
- mixed
Additional data-* attributes. They will each be added with a "data-" prefix.
aria
-
- Type
- mixed
Additional aria-* attributes. They will each be added with a "aria-" prefix.
action
-
- Type
- string
Target action
arguments
-
- Type
- mixed
- Default
array
()
Arguments (do not use reserved keywords "action", "controller" or "format" if not referring to these internal variables specifically)
controller
-
- Type
- string
Target controller
extensionName
-
- Type
- string
Target Extension Name (without
tx_
prefix and no underscores). If NULL the current extension name is used
pluginName
-
- Type
- string
Target plugin. If empty, the current plugin name is used
pageUid
-
- Type
- mixed
Target page uid
object
-
- Type
- mixed
Object to use for the form. Use in conjunction with the "property" attribute on the sub tags
pageType
-
- Type
- mixed
Target page type
noCache
-
- Type
- boolean
Set this to disable caching for the target page. You should not need this.
section
-
- Type
- string
The anchor to be added to the action URI (only active if $actionUri is not set)
format
-
- Type
- string
The requested format (e.g. ".html") of the target page (only active if $actionUri is not set)
additionalParams
-
- Type
- mixed
- Default
array
()
Additional action URI query parameters that won't be prefixed like $arguments (overrule $arguments) (only active if $actionUri is not set)
absolute
-
- Type
- boolean
If set, an absolute action URI is rendered (only active if $actionUri is not set)
addQueryString
-
- Type
- boolean
If set, the current query parameters will be kept in the action URI (only active if $actionUri is not set)
argumentsToBeExcludedFromQueryString
-
- Type
- mixed
- Default
array
()
Arguments to be removed from the action URI. Only active if $addQueryString = TRUE and $actionUri is not set
addQueryStringMethod
-
- Type
- string
This argument is not evaluated anymore and will be removed in TYPO3 v12.
fieldNamePrefix
-
- Type
- string
Prefix that will be added to all field names within this form. If not set the prefix will be tx_yourExtension_plugin
actionUri
-
- Type
- string
Can be used to overwrite the "action" attribute of the form tag
objectName
-
- Type
- string
Name of the object that is bound to this form. If this argument is not specified, the name attribute of this form is used to determine the FormObjectName
hiddenFieldClassName
-
- Type
- string
HiddenFieldClassName
enctype
-
- Type
- string
MIME type with which the form is submitted
method
-
- Type
- string
Transfer type (GET or POST)
name
-
- Type
- string
Name of form
onreset
-
- Type
- string
JavaScript: On reset of the form
onsubmit
-
- Type
- string
JavaScript: On submit of the form
target
-
- Type
- string
Target attribute of the form
novalidate
-
- Type
- boolean
Indicate that the form is not to be validated on submit.
class
-
- Type
- string
CSS class(es) for this element
dir
-
- Type
- string
Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)
id
-
- Type
- string
Unique (in this file) identifier for this HTML element.
lang
-
- Type
- string
Language for this element. Use short names specified in RFC 1766
style
-
- Type
- string
Individual CSS styles for this element
title
-
- Type
- string
Tooltip text of element
accesskey
-
- Type
- string
Keyboard shortcut to access this element
tabindex
-
- Type
- integer
Specifies the tab order of this element
onclick
-
- Type
- string
JavaScript evaluated for the onclick event