Skip to content

Commit

Permalink
bug #15065 [Form] Fixed: remove quoted strings from Intl date formats…
Browse files Browse the repository at this point in the history
… (e.g. es_ES full pattern) (webmozart)

This PR was merged into the 2.3 branch.

Discussion
----------

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

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15042
| License       | MIT
| Doc PR        | -

Commits
-------

5571caa [Form] Fixed: remove quoted strings from Intl date formats (e.g. es_ES full pattern)
  • Loading branch information
fabpot committed Jun 22, 2015
2 parents 25a50f5 + 5571caa commit 92b0283
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Expand Up @@ -145,6 +145,10 @@ public function finishView(FormView $view, FormInterface $form, array $options)

// 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);
}

Expand Down
Expand Up @@ -614,6 +614,20 @@ public function testDontPassDatePatternIfText()
$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(
Expand Down

0 comments on commit 92b0283

Please sign in to comment.