symfony - symfony2 date field type format option changes input type to text -


when do:

    $builder->add('submittedat_min',                     'date',                     array('widget' => 'single_text', 'label' => 'my label', 'attr' => array('placeholder' => 'my placeholder'))); 

i get:

    <input type="date" placeholder="my placeholder" required="required" name="es_app_filter[submittedat_min]" id="es_app_filter_submittedat_min" class="hasdatepicker"> 

the type "date"

but when add format option field:

    $builder->add('submittedat_min',                     'date',                     array('format' => 'dd-mm-yyyy', 'widget' => 'single_text', 'label' => 'my label', 'attr' => array('placeholder' => 'my placeholder'))); 

i get:

      <input type="text" placeholder="my placeholder" required="required" name="es_app_filter[submittedat_min]" id="es_app_filter_submittedat_min"> 

the input type 'text'.

i several things in jquery basing on [type="date"]. when changes "text" action wont work.

any ideas why way, how fix it, workaround?

so got answer symfony issuetracker.

see comment here https://github.com/symfony/form/blob/master/extension/core/type/datetype.php#l130 field type set "date" if format matches 1 expected html5 ( yyyy-mm-dd )  

the comment is:

    // change input html5 date input if     //  * widget set "single_text"     //  * format matches 1 expected html5     if ('single_text' === $options['widget'] && self::html5_format === $options['format']) {         $view->vars['type'] = 'date';     } 

https://github.com/symfony/form/blob/master/extension/core/type/datetype.php#l130

it's not bug, it's feature.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -