English spoken conference

Symfony 5: The Fast Track

A new book to learn about developing modern Symfony 5 applications.

Support this project

New in Symfony 4.3: Form improvements

Added a Twig function to get the parent form

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

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:

$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

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.

use Symfony\Component\Form\Extension\Core\Type\DateTimeType;

$builder->add('startsAt', DateTimeType::class, [
    // ...,
    'input' => 'string',
    'input_format' => 'm-d H:i',


Configure the input format of DateType and DateTimeType

Finally an end to custom form types that follow Y-m-d [H:i:s] or something similar via awkward configs

Thanks a bunch!
Nice, I just wish it was called form_parent instead of parent_form because all the other form functions start with form_* ...
Cornelius: You're right. We've just done the rename (blog post updated).

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.