Documentation · ViewHelper reference

FormViewHelper


Form view helper. Generates a
Tag. = Basic usage =
Use <f:form> to output an HTML 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.

Example

<f:form action="...">...</f:form>
= 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.textbox property="name" />
</f:form>

This automatically inserts the value of {customer.name} inside the textbox and adjusts the name of the textbox accordingly. /
  • Tag usage example

    <f:form additionalAttributes="{foo: 'bar'}" data="{foo: 'bar'}" action="NULL" arguments="{foo: 'bar'}" controller="NULL" extensionName="NULL" pluginName="NULL" pageUid="123" object="[mixed]" pageType="123" noCache="1" noCacheHash="1" section="''" format="''" additionalParams="{foo: 'bar'}" absolute="1" addQueryString="1" argumentsToBeExcludedFromQueryString="{foo: 'bar'}" fieldNamePrefix="NULL" actionUri="NULL" objectName="NULL" hiddenFieldClassName="NULL" enctype="NULL" method="NULL" name="NULL" onreset="NULL" onsubmit="NULL" class="NULL" dir="NULL" id="NULL" lang="NULL" style="NULL" title="NULL" accesskey="NULL" tabindex="123" onclick="NULL">
    	<!-- tag content - may be ignored! -->
    </f:form>
  • Inline usage example

    {f:form(additionalAttributes: {foo: 'bar'}, data: {foo: 'bar'}, action: 'NULL', arguments: {foo: 'bar'}, controller: 'NULL', extensionName: 'NULL', pluginName: 'NULL', pageUid: 123, object: [mixed], pageType: 123, noCache: 1, noCacheHash: 1, section: '''', format: '''', additionalParams: {foo: 'bar'}, absolute: 1, addQueryString: 1, argumentsToBeExcludedFromQueryString: {foo: 'bar'}, fieldNamePrefix: 'NULL', actionUri: 'NULL', objectName: 'NULL', hiddenFieldClassName: 'NULL', enctype: 'NULL', method: 'NULL', name: 'NULL', onreset: 'NULL', onsubmit: 'NULL', class: 'NULL', dir: 'NULL', id: 'NULL', lang: 'NULL', style: 'NULL', title: 'NULL', accesskey: 'NULL', tabindex: 123, onclick: 'NULL')}

Arguments

Argument Description Type
absolute

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

boolean
accesskey

Keyboard shortcut to access this element

string
action

Target action

string
actionUri

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

string
addQueryString

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

boolean
additionalAttributes

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

array
additionalParams

additional action URI query parameters that won't be prefixed like $arguments (overrule $arguments) (only active if $actionUri is not set)

array
arguments

Arguments

array
argumentsToBeExcludedFromQueryString

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

array
class

CSS class(es) for this element

string
controller

Target controller

string
data

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

array
dir

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

string
enctype

MIME type with which the form is submitted

string
extensionName

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

string
fieldNamePrefix

Prefix that will be added to all field names within this form. If not set the prefix will be txyourExtensionplugin

string
format

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

string
hiddenFieldClassName string
id

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

string
lang

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

string
method

Transfer type (GET or POST)

string
name

Name of form

string
noCache

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

boolean
noCacheHash

set this to suppress the cHash query parameter created by TypoLink. You should not need this.

boolean
object

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

mixed
objectName

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

string
onclick

JavaScript evaluated for the onclick event

string
onreset

JavaScript: On reset of the form

string
onsubmit

JavaScript: On submit of the form

string
pageType

Target page type

integer
pageUid

Target page uid

integer
pluginName

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

string
section

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

string
style

Individual CSS styles for this element

string
tabindex

Specifies the tab order of this element

integer
title

Tooltip text of element

string
Required attribute

Revision history

commit 3390bd05f546bccfc9ca5cb012d291f7bdd63512
Author: Claus Due <*****@namelesscoder.net>
Date:   Mon Dec 2 23:26:43 2013 +0100

    [TASK] Rename ViewHelpers
    
    Renames:
    
    flux:flexform -> flux:form
    flux:flexform.field.* -> flux:field.*
    flux:flexform.field.wizard -> flux:wizard.*
    flux:flexform.* -> flux:form.*

commit 3878c943a6eb0924bb6db2e5ed8461580896431f
Author: Claus Due <*****@namelesscoder.net>
Date:   Tue Dec 10 01:59:34 2013 +0100

    [TASK] Update copyright and author tags
    
    Assumes "Claus Due" as author whenever no author is specified.

commit 774bc8704b02e3a8b08561b24aa7c58a4cb79a92
Author: Claus Due <*****@namelesscoder.net>
Date:   Wed Dec 11 22:41:37 2013 +0100

    [TASK] Support form variable stored in template variables

commit b37dbbd83d210d12d1f0b2517b06818225ea3608
Author: Claus Due <*****@namelesscoder.net>
Date:   Tue Dec 17 17:30:12 2013 +0100

    [FEATURE] Storage of custom variables on FormComponents
    
    This allows a "variables" property to be used on every Form component and ViewHelper. Setting an array of variables here, makes those variables available anywhere the Form object is available.
    
    Can, for example, be used to store custom rendering instructions for the Preview section as described in #411

commit 8bf2b5beb89c7d72a41230f152d9a5a3d308ba84
Author: Claus Due <*****@namelesscoder.net>
Date:   Tue Dec 31 23:11:00 2013 +0100

    [TASK] Happy new year!

commit f0ee440ea328f84e22770b1c99a449305a91412c
Author: Claus Due <*****@namelesscoder.net>
Date:   Wed Apr 2 00:30:06 2014 +0200

    [TASK] Support missing "options" argument on flux:form

commit 593885343f601d17d642b4480b88c17d029435d4
Author: Danilo Bürger <*****@hmspl.de>
Date:   Sun May 18 22:08:45 2014 +0200

    [TASK] Add localLanguageFileRelativePath to flux:form

commit 9de10c5eb9479802cda2440d2cbb30a4bfe294d6
Author: Claus Due <*****@namelesscoder.net>
Date:   Tue Jul 29 15:15:30 2014 +0200

    [TASK] Deprecate wizardTab and icon attributes on Form
    
    This change:
    
    * Marks as deprecated in code and rendered documentation, the arguments `wizardTab` and `icon` on `flux:form` in favour of the `options` attribute which is an array that can contain a `group` (equivalent of `wizardTab`) and an `icon` member.
    * Removes properties on `FluidTYPO3\Flux\Form` but leaves in place getter and setter with deprecation logging, redirects storage to `options` class member.
    * Introduces `OPTION_*` constants on `FluidTYPO3\Flux\Form` which define supported options. Other extensions are expected to either use what is provided here or introduce own constants (as constants in their own extension's namespace).

commit 6f5a3094e448fb38a3cad85712160d5be16dae50
Author: Claus Due <*****@namelesscoder.net>
Date:   Mon Oct 6 21:51:21 2014 +0200

    [TASK] Coverage, ViewHelper scope
    
    One noteworthy refactoring: introduce constant for LLL relative path on Form/FormViewHelper.