[Form] Fixed: remove quoted strings from Intl date formats (e.g. es_ES full pattern)

This commit is contained in:
Bernhard Schussek 2015-06-22 17:14:39 +02:00
parent 25a50f5b55
commit 5571caa305
2 changed files with 18 additions and 0 deletions

View File

@ -145,6 +145,10 @@ class DateType extends AbstractType
// remove special characters unless the format was explicitly specified
if (!is_string($options['format'])) {
// remove quoted strings first
$pattern = preg_replace('/\'[^\']+\'/', '', $pattern);
// remove remaining special chars
$pattern = preg_replace('/[^yMd]+/', '', $pattern);
}

View File

@ -614,6 +614,20 @@ class DateTypeTest extends TestCase
$this->assertFalse(isset($view->vars['date_pattern']));
}
public function testDatePatternFormatWithQuotedStrings()
{
\Locale::setDefault('es_ES');
$form = $this->factory->create('date', null, array(
// EEEE, d 'de' MMMM 'de' y
'format' => \IntlDateFormatter::FULL,
));
$view = $form->createView();
$this->assertEquals('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']);
}
public function testPassWidgetToView()
{
$form = $this->factory->create('date', null, array(