Skip to content

[Form] DateType widget choice - always render months as numbers #23064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
krafas opened this issue Jun 5, 2017 · 2 comments
Closed

[Form] DateType widget choice - always render months as numbers #23064

krafas opened this issue Jun 5, 2017 · 2 comments

Comments

@krafas
Copy link

krafas commented Jun 5, 2017

Now Symfony DateType has 3 widget types: choice, text, single_text.

When using widget type choice the format is y-M-d and can't be changed, see: https://github.com/symfony/symfony/blob/v3.3.0/src/Symfony/Component/Form/Extension/Core/Type/DateType.php#L73

We have business requirement, that months always must be rendered as numbers (from 01 to 12). What is the best way to achieve this?

@yceruto
Copy link
Member

yceruto commented Jun 5, 2017

We have business requirement, that months always must be rendered as numbers (from 01 to 12). What is the best way to achieve this?

$form = $this->createFormBuilder()
    ->add('birthday', DateType::class, [
        'widget' => 'choice',
        'format' => 'MM-d-y',
    ])
    ->getForm();

date_type

@krafas krafas closed this as completed Jun 5, 2017
@krafas
Copy link
Author

krafas commented Jun 5, 2017

Thank you, @yceruto!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants