You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a single_text datetime widget is created with a custom date_format, it gets ignored and the HTML5 format gets used.
This is because:
in setDefaultOptions(), the default for format is set to the HTML5 format
in buildForm(), for single_text widgets, the DateTimeToRfc3339Transformer is used, because the default option for format is the HTML5 format. The date_format option is completely ignored
The documentation for the datetime form type is very confusing. This form type uses both format and date_format, but the documentation does not mention anything about a format option.
Only the date_format option is documented, and its description links to the documentation for format on the date widget.
Broken code:
//`date_format` is ignored. `format` is used (defaults to the HTML5 format)
$builder->add('field', 'datetime', array(
'widget' => 'single_text',
'date_format' => 'CUSTOM'
));
Working code:
//The CUSTOM format is used (overrides the default `format` HTML5 value)
$builder->add('field', 'datetime', array(
'widget' => 'single_text',
'format' => 'CUSTOM'
));
Perhaps date_format should be removed completely and format should be documented.
This affects Symfony 2.1 and most likely 2.2 as well (judging by the code).
The text was updated successfully, but these errors were encountered:
… to disable HTML5 input type (csanquer)
This PR was merged into the 2.6-dev branch.
Discussion
----------
[Form] Add allow_html5 option to date and time FormType to disable HTML5 input type
[Form] added allow_html5 option to date and time FormType to disable HTML5 input type when widget is set to single_text
| Q | A
| --------------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #6927#7123
| License | MIT
| Doc PR |
With this little patch we can have a single text widget without HTML5 date input type which is required when using some javascript date or time picker .
Commits
-------
392d6c7 add allow_html5 option to date and time FormType to disable HTML5 date input when widget is set to single_text
When a single_text datetime widget is created with a custom
date_format
, it gets ignored and the HTML5 format gets used.This is because:
setDefaultOptions()
, the default forformat
is set to the HTML5 formatbuildForm()
, for single_text widgets, theDateTimeToRfc3339Transformer
is used, because the default option forformat
is the HTML5 format. Thedate_format
option is completely ignoredThe documentation for the datetime form type is very confusing. This form type uses both
format
anddate_format
, but the documentation does not mention anything about aformat
option.Only the
date_format
option is documented, and its description links to the documentation forformat
on the date widget.Broken code:
Working code:
Perhaps
date_format
should be removed completely andformat
should be documented.This affects Symfony 2.1 and most likely 2.2 as well (judging by the code).
The text was updated successfully, but these errors were encountered: