Argument ViewHelper <f:argument>
f: allows to define requirements and type constraints to variables that
are provided to templates and partials. This can be very helpful to document how
a template or partial is supposed to be used and which input variables are required.
These requirements are enforced during rendering of the template or partial:
If an argument is defined with this ViewHelper which isn't marked as optional,
an exception will be thrown if that variable isn't present during rendering.
If a variable doesn't match the specified type and can't be converted automatically,
an exception will be thrown as well.
Note that f: ViewHelpers must be used at the root level of the
template, and can't be nested into other ViewHelpers. Also, the usage of variables
in any of its arguments is not possible (e. g. you can't define an argument name
by using a variable).
Rendering of specific sections will not validate argument constraints. They will only be evaluated if the template or partial is rendered directly.
Go to the source code of this ViewHelper: ArgumentViewHelper.php (GitHub).
Arguments of the <f:argument> ViewHelper
default
-
- Type
- mixed
default value for optional argument
description
-
- Type
- string
description of the template argument
name
-
- Type
- string
- Required
- 1
name of the template argument
optional
-
- Type
- boolean
- Default
- false
true if the defined argument should be optional
type
-
- Type
- string
- Required
- 1
type of the template argument