whitebear
whitebear

Reputation: 12435

show month number instead of month name on symfony2 formbuilder

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

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

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

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

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

How can I make it ?

Upvotes: 0

Views: 474

Answers (1)

vobence
vobence

Reputation: 523

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',
    // ...
));

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.

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

Upvotes: 4

Related Questions