symfony/symfony — Issue #3387: [Form] DateType buildViewBottomUp pattern selection does not follow documented behavior 
Author: dcousineau
Created: 2012-02-16 21:13:11+00:00
State: open

The form component DateType does not follow the documented behavior and naive selection process breaks any attempt to utilize the DateType element pattern field.

According to the [official documentation](http://symfony.com/doc/2.0/reference/forms/types/date.html#pattern) the DateType will first check for the `pattern` configuration. If none is set, it will attempt to convert the `format` option. Finally if neither are set it will use a default pattern.

If you notice the [relevant code (DateType.php line 147)](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/Type/DateType.php#L147) you will see the pattern selection completely ignores the `pattern` option (instead pulls in the `format`), the regex on line 156 in using the 3 matching groups accidentally requires that 3 fields be present (even though those 3 fields could be the same portion, e.g. 3 year dropdowns).

Essentially as of right now the behavior is: `pattern` is ignored, and `format` requires at least 3 elements. I will work on a patch for now to conform to documented behavior.