Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2.0 datetime widget; how to render with JQuery UI date picker?

I have a Symfony 2.0 app.

It has a datetime field on an entity, and a datetime field on a form.

How can I have the date part of that form render with a jQuery UI date picker instead of the 3 select boxes?

Thanks,

EDIT

This is what I have so far:

$builder->add('start_at', 'datetime',array('date_widget' => 'single_text'));

This puts a text box on the page for the date then 2 select boxes for the time, and you can easily add a jQuery UI on top of that!

The problem is the Symfony datetime field only accepts input in the format "Aug 29, 2012". If the user types in "Aug 29 2012" or "29 Aug 2012" it refuses to validate.

So anyone who can fix that problem or suggest an entirely different working approach would be much appreciated.

like image 859
James Avatar asked Aug 30 '12 12:08

James


2 Answers

Take a look at this bundle. It provides several extra form types, including a jquery date form field:

https://github.com/genemu/GenemuFormBundle

like image 37
Carlos Granados Avatar answered Nov 18 '22 06:11

Carlos Granados


I ended up using this code

    $builder->add('start_at', 'datetime' ,array(
            'date_widget'=> 'single_text',
            'date_format'=>'d/M/y',
            ....
        ));

then putting jQuery UI on top of it, and just dealing with the fact that it only accepts input in one format only.

like image 157
James Avatar answered Nov 18 '22 05:11

James