我正在尝试在我的Symfony2应用中为表单的'birthday'datetype添加'format'属性。添加之后,我从jquery-ui中丢失了datepicker功能(datepicker没有加载)。
dob.php
->add('dob', 'birthday', array(
'invalid_message'=>'<a href="#[redacted]" >Date of birth is not a valid date</a>',
'widget' => 'single_text',
'format' => 'MM/dd/yyyy', // the line at fault
'label' => 'Birthday',
'years' => range(mindate,maxdate), // redacted
'error_bubbling' => 'true',
'data' => getcurrentDate(), // redacted
'attr' => array(
'class' => 'datePicker'
)
))
app.js
/* Show native datepicker when supported in browser else show jQuery's datepicker */
if (!Modernizr.inputtypes.date) {
var date = new Date();
var thisYear = date.getFullYear();
$('input[type=date]').datepicker({
// Consistent format with the HTML5 picker
defaultDate: new Date(thisYear - 18, 6 - 1, 15),
dateFormat: 'mm/dd/yy',
yearRange: '-120:-10',
changeMonth: true,
changeYear: true
});
}
Symfony版本:2.6.7 Jquery-UI版本:1.11.x