FormExtension
class FormExtension extends Twig_Extension implements Twig_Extension_InitRuntimeInterface
FormExtension extends Twig with form capabilities.
Properties
TwigRendererInterface | $renderer | This property is public so that it can be accessed directly from compiled templates without having to call a getter, which slightly decreases performance. |
Methods
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
Makes a technical name human readable.
Returns whether a choice is selected for a given form value.
{@inheritdoc}
Details
at line line 34
__construct(TwigRendererInterface $renderer)
at line line 42
initRuntime(Twig_Environment $environment)
{@inheritdoc}
at line line 50
getTokenParsers()
{@inheritdoc}
at line line 61
getFunctions()
{@inheritdoc}
at line line 79
getFilters()
{@inheritdoc}
at line line 89
getTests()
{@inheritdoc}
at line line 99
renderCsrfToken($tokenId)
{@inheritdoc}
at line line 111
string
humanize(string $text)
Makes a technical name human readable.
at line line 139
bool
isSelectedChoice(ChoiceView $choice, string|array $selectedValue)
Returns whether a choice is selected for a given form value.
Unfortunately Twig does not support an efficient way to execute the "is_selected" closure passed to the template by ChoiceType. It is faster to implement the logic here (around 65ms for a specific form).
Directly implementing the logic here is also faster than doing so in ChoiceView (around 30ms).
The worst option tested so far is to implement the logic in ChoiceView and access the ChoiceView method directly in the template. Doing so is around 220ms slower than doing the method call here in the filter. Twig seems to be much more efficient at executing filters than at executing methods of an object.
at line line 151
getName()
{@inheritdoc}