Added a Twig function to get the parent form
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
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
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',
]);
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).
awesome!