TwigForm

Extension
in package
implements ExtensionInterface

Twig extension providing usefull functions for working with forms

Table of Contents

Interfaces

ExtensionInterface

Methods

getFilters()  : array<string|int, TwigFilter>
Returns a list of filters to add to the existing list.
getFunctions()  : array<string|int, TwigFunction>
Returns a list of functions to add to the existing list.
getNodeVisitors()  : array<string|int, NodeVisitorInterface>
Returns the node visitor instances to add to the existing list.
getOperators()  : array<string|int, array<string|int, mixed>>
Returns a list of operators to add to the existing list.
getTests()  : array<string|int, TwigTest>
Returns a list of tests to add to the existing list.
getTokenParsers()  : array<string|int, TokenParserInterface>
Returns the token parser instances to add to the existing list.

Methods

getFilters()

Returns a list of filters to add to the existing list.

public getFilters() : array<string|int, TwigFilter>

Not used until now ...

Return values
array<string|int, TwigFilter>

getFunctions()

Returns a list of functions to add to the existing list.

public getFunctions() : array<string|int, TwigFunction>
Return values
array<string|int, TwigFunction>
Twig function form_open

Twig function to open an HTML form by a provisioned <form> tag.

Usage:

{{ form_open( attributes ) }}

The parameter attributes is a dictionary (key-value-list) for provisioning the <form> tag.

Key-names can be all valid attribute names of the <form> tag, see w3schools.com.

Some specials do exist:

  • method defaults to POST; if not GET or POST, an additional _method input of hidden type will be added.
  • You can add the additional attribute token, if you want to add a hidden input with the name _token e.g. to use your CSRF token within the form.
  • If no enctype attribute is given, this extension uses multipart/form-data by default.
  • Since this extension is part of TwigForm, which uses Bootstrap (version 5) for styling, our form class attribute defaults to form-horizontal – please adjust for your needs.
  • You can also add only additional classes without overriding the already mentioned class attribute by using add_class attribute – it takes one string to be appended to the actual class attribute
Twig function form_close

Twig function that returns a </form> tag; closing of form_open function.

Usage:

{{ form_close() }}
Twig function request_data

Twig function that returns a value out of the default global $_REQUEST, $_GET or $_POST variables.

Usage:

{{ request_data( name [, default [, method ]] ) }}
  • name is the string value of the name to be looked for
  • default (optional) is a default value to be returned, if variable does not exist
  • method (optional) represents the specific method to be looked into – GET, POST or REQUEST. If no value given, the function defaults it to NULL and then will use $_REQUEST for lookup.

getNodeVisitors()

Returns the node visitor instances to add to the existing list.

public getNodeVisitors() : array<string|int, NodeVisitorInterface>

Not used until now ...

Return values
array<string|int, NodeVisitorInterface>

getOperators()

Returns a list of operators to add to the existing list.

public getOperators() : array<string|int, array<string|int, mixed>>

Not used until now ...

Return values
array<string|int, array<string|int, mixed>>

First array of unary operators, second array of binary operators

getTests()

Returns a list of tests to add to the existing list.

public getTests() : array<string|int, TwigTest>

Not used until now ...

Return values
array<string|int, TwigTest>

getTokenParsers()

Returns the token parser instances to add to the existing list.

public getTokenParsers() : array<string|int, TokenParserInterface>

Not used until now ...

Return values
array<string|int, TokenParserInterface>

        
On this page

Search results