New in Symfony 3.4: Form improvements
October 5, 2017 • Published by Javier Eguiluz
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
New HTML5 types
Contributed by
Arnaud Petitpas
in #22679.
The HTML5 specification defines several form fields that are still not supported
by Symfony Forms. In Symfony 3.4 we implemented two of these new HTML5 form
fields which have a good support in modern browsers: TelType
(for telephone
numbers) and ColorType
(for color pickers).
New options for TimezoneType
Contributed by
Roland Franssen
in #23648.
The TimezoneType
defines two new options: input
and regions
. The
input
option defines the format that the timezone is stored in your
underlying object. The value can be string
(e.g. America/New_York
) and
datetimezone
(which returns a DateTimeZone
object).
The regions
option filters the timezones to only display the ones that belong
to the given region or regions. For example, to display just the timezones of
Europe and America: DateTimeZone::AMERICA | DateTimeZone::EUROPE
.
Callbacks in the delete_empty
option
Contributed by
Konstantin Myakshin
in #20496.
In addition to boolean values, the delete_empty
now accepts PHP callbacks to
decide if items should be deleted. In case of compound entries, you can now do this:
1 2 3
'delete_empty' => function (Author $author = null) {
return null === $author || empty($author->firstName);
},
In case of compound entries without data_class
:
1 2 3
'delete_empty' => function ($author) {
return empty($author['firstName']);
},
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
Thanks