jQuery UI datepicker失去了'birthday'datetype格式的功能

时间:2015-05-15 17:43:19

标签: jquery-ui symfony jquery-ui-datepicker

我正在尝试在我的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

1 个答案:

答案 0 :(得分:0)

你必须像这样指定输入类型:

->add('dob', 'date', ...)

请参阅Symfony2 Forms