Symfony 2: How to render date field without a day?

Viewed 6625

I'm trying to build form with date field, where user can pick a month and year only (without day of month), but i can't figure out how to achieve this.

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder->add(
        'month',
        'date',
        array(
            'label' => 'Month & year',
            'input' => 'array',
            'widget' => 'choice',
        ));

    $builder->add('submit',
                  'submit');
}

Ideal result is two dropdown lists: list of months (number representation) and list of years (4 digit, 5 last years).

I think i can use 2 choice type fields but maybe there is a more elegant solution?

4 Answers
Related