Form ViewHelper <f:form>

Form ViewHelper. Generates a <form> Tag. Tailored for extbase plugins, uses extbase Request.

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
string
mixed array ()
string
string
string
string
mixed
string
string
string 'post'
string
string
string
string
boolean
string
string
string
string
string
string
string
integer
string
additionalAttributes
Type
mixed
Required

true

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

data
Type
mixed
Required

true

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

aria
Type
mixed
Required

true

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

action
Type
string
Required

true

Target action

arguments
Type
mixed
Required

true

Default
array ()

Arguments

controller
Type
string
Required

true

Target controller

extensionName
Type
string
Required

true

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

pluginName
Type
string
Required

true

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

pageUid
Type
mixed
Required

true

Target page uid

object
Type
mixed
Required

true

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

pageType
Type
mixed
Required

true

Target page type

noCache
Type
boolean
Required

true

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

section
Type
string
Required

true

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

format
Type
string
Required

true

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

additionalParams
Type
mixed
Required

true

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
Required

true

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

addQueryString
Type
string
Required

true

If set, the current query parameters will be kept in the URL. If set to "untrusted", then ALL query parameters will be added. Be aware, that this might lead to problems when the generated link is cached.

argumentsToBeExcludedFromQueryString
Type
mixed
Required

true

Default
array ()

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

fieldNamePrefix
Type
string
Required

true

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
Required

true

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

objectName
Type
string
Required

true

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
Required

true

HiddenFieldClassName

requestToken
Type
mixed
Required

true

Whether to add that request token to the form

signingType
Type
string
Required

true

Which signing type to be used on the request token (falls back to "nonce")

enctype
Type
string
Required

true

MIME type with which the form is submitted

method
Type
string
Required

true

Default
'post'

Transfer type (get or post)

name
Type
string
Required

true

Name of form

onreset
Type
string
Required

true

JavaScript: On reset of the form

onsubmit
Type
string
Required

true

JavaScript: On submit of the form

target
Type
string
Required

true

Target attribute of the form

novalidate
Type
boolean
Required

true

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

class
Type
string
Required

true

CSS class(es) for this element

dir
Type
string
Required

true

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

id
Type
string
Required

true

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

lang
Type
string
Required

true

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

style
Type
string
Required

true

Individual CSS styles for this element

title
Type
string
Required

true

Tooltip text of element

accesskey
Type
string
Required

true

Keyboard shortcut to access this element

tabindex
Type
integer
Required

true

Specifies the tab order of this element

onclick
Type
string
Required

true

JavaScript evaluated for the onclick event