Form ViewHelper <f:form>

Form ViewHelper. Generates a <form> Tag.

Basic usage

Use <f:form> 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>
Copied!

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>
Copied!

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:form>:

Name Type Default
mixed
mixed
mixed
string
mixed array ()
string
string
string
mixed
mixed
mixed
boolean
string
string
mixed array ()
boolean
boolean
mixed array ()
string
string
string
string
string
string
string
string
string
string
string
boolean
string
string
string
string
string
string
string
integer
string

additionalAttributes

additionalAttributes
Type
mixed

Additional tag attributes. They will be added directly to the resulting HTML tag.

data

data
Type
mixed

Additional data-* attributes. They will each be added with a "data-" prefix.

aria

aria
Type
mixed

Additional aria-* attributes. They will each be added with a "aria-" prefix.

action

action
Type
string

Target action

arguments

arguments
Type
mixed
Default
array ()

Arguments (do not use reserved keywords "action", "controller" or "format" if not referring to these internal variables specifically)

controller

controller
Type
string

Target controller

extensionName

extensionName
Type
string

Target Extension Name (without tx_ prefix and no underscores). If NULL the current extension name is used

pluginName

pluginName
Type
string

Target plugin. If empty, the current plugin name is used

pageUid

pageUid
Type
mixed

Target page uid

object

object
Type
mixed

Object to use for the form. Use in conjunction with the "property" attribute on the sub tags

pageType

pageType
Type
mixed

Target page type

noCache

noCache
Type
boolean

Set this to disable caching for the target page. You should not need this.

section

section
Type
string

The anchor to be added to the action URI (only active if $actionUri is not set)

format

format
Type
string

The requested format (e.g. ".html") of the target page (only active if $actionUri is not set)

additionalParams

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

absolute
Type
boolean

If set, an absolute action URI is rendered (only active if $actionUri is not set)

addQueryString

addQueryString
Type
boolean

If set, the current query parameters will be kept in the action URI (only active if $actionUri is not set)

argumentsToBeExcludedFromQueryString

argumentsToBeExcludedFromQueryString
Type
mixed
Default
array ()

Arguments to be removed from the action URI. Only active if $addQueryString = TRUE and $actionUri is not set

addQueryStringMethod

addQueryStringMethod
Type
string

This argument is not evaluated anymore and will be removed in TYPO3 v12.

fieldNamePrefix

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

actionUri
Type
string

Can be used to overwrite the "action" attribute of the form tag

objectName

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

hiddenFieldClassName
Type
string

HiddenFieldClassName

enctype

enctype
Type
string

MIME type with which the form is submitted

method

method
Type
string

Transfer type (GET or POST)

name

name
Type
string

Name of form

onreset

onreset
Type
string

JavaScript: On reset of the form

onsubmit

onsubmit
Type
string

JavaScript: On submit of the form

target

target
Type
string

Target attribute of the form

novalidate

novalidate
Type
boolean

Indicate that the form is not to be validated on submit.

class

class
Type
string

CSS class(es) for this element

dir

dir
Type
string

Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)

id

id
Type
string

Unique (in this file) identifier for this HTML element.

lang

lang
Type
string

Language for this element. Use short names specified in RFC 1766

style

style
Type
string

Individual CSS styles for this element

title

title
Type
string

Tooltip text of element

accesskey

accesskey
Type
string

Keyboard shortcut to access this element

tabindex

tabindex
Type
integer

Specifies the tab order of this element

onclick

onclick
Type
string

JavaScript evaluated for the onclick event