I use Symfony 4.3 and 'bootstrap_4_layout.html.twig' as form theme. How can I setup DateType field to show month numbers instead of month names?
{{ form_widget(formConge.DateBureauOrdre.month, {'var': {'choices': {'label': {'jan': 'a' }} } }) }}
I use Symfony 4.3 and 'bootstrap_4_layout.html.twig' as form theme. How can I setup DateType field to show month numbers instead of month names?
{{ form_widget(formConge.DateBureauOrdre.month, {'var': {'choices': {'label': {'jan': 'a' }} } }) }}
If you are using a DateType
form field, you have an option there called format
which can be used to format the day & month & year fields.
More information can be found on Symfony Documentation
You would better pay attention to deprecation notice:
Deprecated since version 4.3: Using the format option when the html5 option is enabled is deprecated since Symfony 4.3.
You can use the Twig date format for this purposes, something like the following:
{{ object.date|date('d/m/Y H:i:s') }}
Also, check out this thread: How to render a DateTime object in a Twig template