Added a Twig function to get the parent form

Christian Flothmann
Contributed by Christian Flothmann in #28812

In Symfony 4.3 we added a Twig function called form_parent() which returns the parent form view or null if the form view already is the root form. Using this function should be preferred over accessing the parent form using form.parent. The latter way will produce different results for example when a child form is named parent.

Allow including HTML contents in help messages

Mathieu Piot
Contributed by Mathieu Piot in #29861

The contents of the help message that can be defined for form fields are escaped by default to prevent security issues. If your help messages contain HTML elements (e.g. links to other pages) and you know they are safe to render "as is", set to true the new help_html option added in Symfony 4.3:

1
2
3
4
$builder->add('zip_code', null, [
    'help' => '<a target="_blank" href="...">Look up your ZIP code.</a>',
    'help_html' => true,
]);

Configure the input format of DateType and DateTimeType

Thomas Calvet
Contributed by Thomas Calvet in #29887

In Symfony 4.3 we added a new input_format option to DateType and DateTimeType. If the input option is set to string, this option specifies the format of the date, which must be a valid PHP date format.

1
2
3
4
5
6
7
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;

$builder->add('startsAt', DateTimeType::class, [
    // ...,
    'input' => 'string',
    'input_format' => 'm-d H:i',
]);
Published in #Living on the edge