如何在Symfony2中的日期字段中以全文显示月份?

i.a*_*iel 6 php forms symfony

在表格中使用日期字段与Symfony2时,它们显示在三个不同的选择框中.就像是 :

dd/mm/YYYY
Run Code Online (Sandbox Code Playgroud)

我们想要做的是用文字显示月份January,February而不是1,2,3 ......

如何在月份下拉列表中强制显示全文?

编辑:这是我在表单类中使用的代码:

$builder->add('dateOfBirth', 'birthday', array(
    'format' => 'dd - MM - yyyy',
    'widget' => 'choice',
    'years' => range(date('Y'), date('Y')-70)
));
Run Code Online (Sandbox Code Playgroud)

EDIT2:显示F的图像

在此输入图像描述

gre*_*ire 8

查看DateType类的代码,它有一个格式选项:

$allowedFormatOptionValues = array(
            \IntlDateFormatter::FULL,
            \IntlDateFormatter::LONG,
            \IntlDateFormatter::MEDIUM,
            \IntlDateFormatter::SHORT,
        );

        // If $format is not in the allowed options, it's considered as the pattern of the formatter if it is a string
        if (!in_array($format, $allowedFormatOptionValues, true)) {
            if (is_string($format)) {
                $defaultOptions = $this->getDefaultOptions($options);

                $format = $defaultOptions['format'];
                $pattern = $options['format'];
            } else {
                throw new CreationException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom pattern');
            }
        }

$formatter = new \IntlDateFormatter(
        \Locale::getDefault(),
        $format,
        \IntlDateFormatter::NONE,
        \DateTimeZone::UTC,
        \IntlDateFormatter::GREGORIAN,
        $pattern
    );
Run Code Online (Sandbox Code Playgroud)

UPDATE

$builder->add('dateOfBirth', 'birthday', array(
    'format' => 'dd - MMMM - yyyy',
    'widget' => 'choice',
    'years' => range(date('Y'), date('Y')-70)
));
Run Code Online (Sandbox Code Playgroud)