merged branch bschussek/issue5730 (PR #5962)

This PR was merged into the 2.1 branch.

Commits
-------

0f75586 [Form] Removed an exception that prevented valid formats from being passed, e.g. "h" for the hour, "L" for the month etc.

Discussion
----------

[Form] Removed an exception that prevented valid formats from being passed

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #5730
Todo: -
License of the code: MIT
Documentation PR: -
This commit is contained in:
Fabien Potencier 2012-11-09 17:32:10 +01:00
commit de63128cab

View File

@ -87,10 +87,6 @@ class DateTimeType extends AbstractType
throw new InvalidOptionsException('The "date_format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.');
}
if (null !== $pattern && (false === strpos($pattern, 'y') || false === strpos($pattern, 'M') || false === strpos($pattern, 'd') || false === strpos($pattern, 'H') || false === strpos($pattern, 'm'))) {
throw new InvalidOptionsException(sprintf('The "format" option should contain the letters "y", "M", "d", "H" and "m". Its current value is "%s".', $pattern));
}
if ('single_text' === $options['widget']) {
if (self::HTML5_FORMAT === $pattern) {
$builder->addViewTransformer(new DateTimeToRfc3339Transformer(