genemu/GenemuFormBundle

Add jquery datepicker for datetime fields

Opened this issue · 4 comments

jr-k commented

It would be nice you can add the jquery datepicker for datetime fields.
http://jqueryui.com/datepicker/

Thanks !

It's possible and documented in the documentation.

Poor documentation

I use {{form_stylesheet(myform)}} as documented but my form is not showing at all

Did you use {{ form_javascript(myform) }} too? Have you include jQuery UI librairy? (and jQuery as well?)

Yes, I have all of it too. Documentation is really too short for me also.

I have llok here, and nothing about date AND time.

https://github.com/genemu/GenemuFormBundle/blob/master/Resources/views/Form/jquery_layout.html.twig

I'm going to fork it to implement it.

Here is the code to be implemented and working for me without Genemu:

You need : jquery-datetimepicker/jquery.datetimepicker.js

My Type:
->add('date','datetime',array(
'date_widget' => "single_text", 'time_widget' => "single_text",
'format' => \IntlDateFormatter::SHORT,
'attr' => array('class' => 'date')
))

JAVASCRIPT:
$(function(){
$("#form_event_date_date input").each(function(){
$(this).attr("readonly","readonly");
});
$('#form_event_date_date').datetimepicker({
format: "Y-m-d",
timepicker: false,
datepicker: true,
});
$('#nld_sitebundle_event_date_time').datetimepicker({
format: "H:i",
timepicker: true,
datepicker: false,
step:5
});
});