我在symfony2表单中添加了一个jQuery datepicker.
树枝文件:
$('.date').datepicker({ showOn: 'button',buttonImageOnly: true,changeMonth: true,changeYear: true,dateFormat: 'yy-MM-dd ',yearRange: "-0:+1" });
PostType.PHP
$builder->add('toDate','datetime',array( 'input' => 'datetime','widget' => 'single_text','format' => 'yy-MM-dd','attr' => array('class' => 'date') ));
解决方法
尝试这样的事情
$('.date').datepicker({ showOn: 'button',dateFormat: 'dd-mm-yy','date',array( 'widget' => 'single_text','format' => 'dd-MM-yyyy','attr' => array('class' => 'date') ))