在 symfony2 formbuilder 上显示月份编号而不是月份名称

在 symfony2 formbuilder 上显示月份编号而不是月份名称

问题描述:

这可能是荒谬的问题,但我无法通过谷歌搜索找到方法.

It might be ridiculous quesion, but I can't find the way with googling.

我正在制作这样的表格.
$form = $this->createFormBuilder($searchTime)

I am making form like this.
$form = $this->createFormBuilder($searchTime)

     ->add('date','date',array(
            "property_path" => false,
           'years' => $years,
            'data' => new \Datetime()

但它显示月份选择框作为名称,如 jun,july,aug

but it shows month select box as name such as jun,july,aug

但是我想在这里显示数字 6,7,8 ....

however I want to show number here 6,7,8 ....

我该怎么做?

也许值得一试,指定一个格式,正如参考文献所说:

Maybe it's worth a try to specify a format, as the reference says:

$builder->add('date', 'date', array(
    'widget' => 'choice',
    'format' => 'yyyy-MM-dd',
    // ...
));

参考文献说,如果您的 widgetchoice 并且您指定了 format 那么选择将按照格式.也许选择格式也会调整为格式模式.

The reference says, that if your widget is choice and you specify the format then the selects will be rendered in the order of the format. Maybe the select format is also will be adjusted to the format pattern.

(没有前导零的月份为:yyyy-M-dd)

(The month without leading zeros would be: yyyy-M-dd)