Symfony Display HTML5 Date Picker

Sexy Business Woman Cleavage
While there are many reasons to use Symfony, the form builder is yet another. It’s yet to limit what I want to do, and adds a ton of value.

To enable the HTML5 date picker form widget, just do this.

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('birthday', 'date', array(
                'widget'=>'single_text',
                'format'=>'yyyy-MM-dd'
            ))
        ;
    }

The key is to set the format to “yyyy-MM-dd.” This is in accordance with RFC 3339.

Share Button