在 symfony2 formbuilder 上显示月份编号而不是月份名称 [英] show month number instead of month name on symfony2 formbuilder

查看:22
本文介绍了在 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)

这篇关于在 symfony2 formbuilder 上显示月份编号而不是月份名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆