Documentation · ViewHelper reference

Field / ControllerActionsViewHelper

ControllerActions ViewHelper

Renders a FlexForm select field with options fetched from requested extensionName/pluginName and other settings.

There are three basic ways of adding selection options:

  • You can use the "extensionName" and "pluginName" to render all possible actions from an Extbase plugin that you've defined. It doesn't have to be your own plugin - if for example you are rendering actions from EXT:news or another through your own plugin.
  • Or you can use the "actions" argument which is an array: {ControllerName: 'action1,action2,action3', OtherControllerName: 'action1'}
  • And you can extend any of the two methods above with the "subActions" parameter, which allows you to extend the allowed actions whenever the specified combination of ControllerName + actionName is encountered. Example: actions="{ControllerName: 'action1,action2'}" subActions="{ControllerName: {action1: 'action3,action4'}}" Gives options: ControllerName->action1,action3,action4 with LLL values based on "action1" ControllerName->action2 with LLL values based on "action2" By default Flux will create one option per action when reading Controller actions - using "subActions" it becomes possible to add additional actions to the list of allowed actions that the option will contain, as opposed to having only one action per option.

And there are a few ways to limit the options that are displayed:

  • You can use "excludeActions" to specify an array in the same syntax used by the "actions" argument, these are then excluded.
  • You can specifiy the "controllerName" argument in which case only actions from that Controller are displayed.

And there are a couple of ways to define/resolve labels for actions:

  • You can add an LLL label in your locallang_db file: lowercasepluginname.lowercasecontrollername.actionfunctionname example index: myext.articlecontroller.show
  • You can do nothing, in which case the very first line of the PHP doc-comment of each action method is used. This value can even be an LLL:file reference (in case you don't want to use the pattern above - but beware this is somewhat expensive processing)
  • Or you can do nothing at all, not even add a doc comment, in which case the Controller->action syntax is used instead.

Marking actions that have required arguments (which cause errors if rendered on a page that is accessible through a traditional menu) is possible but is deactivated for LLL labels; if you use LLL labels and your action requires an argument, be user friendly and note so in the LLL label or docs as applies.

Lastly, you can set a custom name for the field in which case the value does not trigger the Extbase SwitchableControllerActions feature but instead works as any other Flux FlexForm field would.

To use the field just place it in your Flux form (but in almost all cases leave out the "name" argument which is required on all other field types at the time of writing this). Where the field is placed is not important; the order and the sheet location don't matter. /

  • Tag usage example

    <flux:field.controllerActions name="'switchableControllerActions'" label="NULL" default="NULL" required="1" exclude="1" transform="NULL" enabled="1" requestUpdate="1" displayCond="NULL" inherit="1" inheritEmpty="1" clear="1" variables="{foo: 'bar'}" extensionName="NULL" validate="'trim'" size="123" multiple="1" minItems="123" maxItems="123" itemListStyle="NULL" selectedListStyle="NULL" renderMode="NULL" items="[mixed]" emptyOption="[mixed]" translateCsvItems="1" renderType="'selectSingle'" showIconTable="1" controllerExtensionName="NULL" pluginName="NULL" controllerName="NULL" actions="{foo: 'bar'}" excludeActions="{foo: 'bar'}" prefixOnRequiredArguments="'*'" disableLocalLanguageLabels="1" localLanguageFileRelativePath="'/Resources/Private/Language/locallang_db.xml'" subActions="{foo: 'bar'}" separator="NULL">
    	<!-- tag content - may be ignored! -->
    </flux:field.controllerActions>
  • Inline usage example

    {flux:field.controllerActions(name: ''switchableControllerActions'', label: 'NULL', default: 'NULL', required: 1, exclude: 1, transform: 'NULL', enabled: 1, requestUpdate: 1, displayCond: 'NULL', inherit: 1, inheritEmpty: 1, clear: 1, variables: {foo: 'bar'}, extensionName: 'NULL', validate: ''trim'', size: 123, multiple: 1, minItems: 123, maxItems: 123, itemListStyle: 'NULL', selectedListStyle: 'NULL', renderMode: 'NULL', items: [mixed], emptyOption: [mixed], translateCsvItems: 1, renderType: ''selectSingle'', showIconTable: 1, controllerExtensionName: 'NULL', pluginName: 'NULL', controllerName: 'NULL', actions: {foo: 'bar'}, excludeActions: {foo: 'bar'}, prefixOnRequiredArguments: ''*'', disableLocalLanguageLabels: 1, localLanguageFileRelativePath: ''/Resources/Private/Language/locallang_db.xml'', subActions: {foo: 'bar'}, separator: 'NULL')}

Arguments

Argument Description Type
actions

Array of "ControllerName" => "csv,of,actions" which are allowed. If used, does not require the use of an ExtensionName and PluginName (will use the one specified in your current plugin automatically)

array
clear

If TRUE, a "clear value" checkbox is displayed next to the field which when checked, completely destroys the current field value all the way down to the stored XML value

boolean
controllerExtensionName

Name of the Extbase extension that contains the Controller to parse, ex. MyExtension. In vendor based extensions use dot, ex. Vendor.MyExtension

string
controllerName

Optional extra limiting of actions displayed - if used, field only displays actions for this controller name - ex Article(Controller) or FrontendUser(Controller) - the Controller part is implied

string
default

Default value for this attribute

string
disableLocalLanguageLabels

If TRUE, disables LLL label usage and just uses the class comment or Controller->action syntax

boolean
displayCond

Optional "Display Condition" (TCA style) for this particular field. See: https://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#displaycond

string
emptyOption

If not-FALSE, adds one empty option/value pair to the generated selector box and tries to use this property's value (cast to string) as label.

mixed
enabled

If FALSE, disables the field in the FlexForm

boolean
exclude

If TRUE, this field becomes an "exclude field" (see TYPO3 documentation about this)

boolean
excludeActions

Array of "ControllerName" => "csv,of,actions" which must be excluded

array
extensionName

If provided, enables overriding the extension context for this and all child nodes. The extension name is otherwise automatically detected from rendering context.

string
inherit

If TRUE, the value for this particular field is inherited - if inheritance is enabled by the ConfigurationProvider

boolean
inheritEmpty

If TRUE, allows empty values (specifically excluding the number zero!) to be inherited - if inheritance is enabled by the ConfigurationProvider

boolean
itemListStyle

Overrides the default list style when maxItems > 1

string
items

Optional, full list of items to display - note: if used, this overrides any automatic option filling!

mixed
label

Label for the attribute, can be LLL: value. Optional - if not specified, Flux tries to detect an LLL label named "flux.fluxFormId.fields.foobar" based on field name, in scope of extension rendering the Flux form. If field is in an object, use "flux.fluxFormId.objects.objectname.foobar" where "foobar" is the name of the field.

string
localLanguageFileRelativePath

Relative (from extension $extensionName) path to locallang file containing the action method labels

string
maxItems

Maxium allowed number of items to be selected

integer
minItems

Minimum required number of items to be selected

integer
multiple

If TRUE, allows multiple selections

boolean
name

Name of the field

string
pluginName

Name of the Extbase plugin that contains Controller definitions to parse, ex. MyPluginName

string
prefixOnRequiredArguments

A short string denoting that the method takes arguments, ex * (which should then be explained in the documentation for your extension about how to setup your plugins

string
renderMode

Alternative rendering mode - default is an HTML select field but you can also use fx "checkbox" - see TCA "select" field "renderType" attribute

string
renderType

Rendering type as applies in FormEngine/TCA

string
requestUpdate

If TRUE, the form is force-saved and reloaded when field value changes

boolean
required

If TRUE, this attribute must be filled when editing the FCE

boolean
selectedListStyle

Overrides the default selected list style when maxItems > 1 and renderMode is default

string
separator

Separator string (glue) for Controller->action values, defaults to "->". Empty values result in default being used.

string
showIconTable

If TRUE shows the option icons as table beneath the select

boolean
size

Size of the selector box

integer
subActions

Array of sub actions {ControllerName: {list: 'update,delete'}, OtherController: {new: 'create'}} which ' . 'are also allowed but not presented as options when the mapped action is selected (in example: if ' . 'ControllerName->list is selected, ControllerName->update and ControllerName->delete are allowed - but ' . 'cannot be selected).

array
transform

Set this to transform your value to this type - integer, array (for csv values), float, DateTime, Vendor\MyExt\Domain\Model\Object or ObjectStorage with type hint.

string
translateCsvItems

If TRUE, attempts to resolve a LLL label for each value provided as CSV in "items" attribute using convention for lookup "$field.option.123" if given "123" as CSV item value. Field name is determined by normal Flux field name conventions

boolean
validate

FlexForm-type validation configuration for this input

string
variables

Freestyle variables which become assigned to the resulting Component - can then be read from that Component outside this Fluid template and in other templates using the Form object from this template

array
Required attribute

Revision history

commit 15a009ef1015adaec1e1e05380180ff00e0fbc06
Author: Danilo Bürger <*****@hmspl.de>
Date:   Tue Dec 10 21:20:22 2013 +0100

    [TASK] Renamed flux field viewhelpers

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

    [TASK] Happy new year!

commit 7e151e5cefb19a080d2d1bea2951cdea2db97b15
Author: G. Bodenschatz <*****@46halbe.de>
Date:   Wed Sep 17 00:46:37 2014 +0200

    [TASK] Add missing aliases