1

I'm (obviously) new to Symfony/Sonata, I have a problem where Sonata admin is wrapping my date choice onto 3 lines.

php:

$form = $this->createFormBuilder($statsForm)
    ->add('startDate', 'date', array('years' => range(2015, date('Y')), 'format' => 'y-M-d', 'widget' => 'choice'))
    ->add('endDate', 'date', array('years' => range(2015, date('Y')), 'format' => 'y-M-d', 'widget' => 'choice'))
    ->getForm();

twig:

{{ form_start(form) }}
<div class="col-md-3">
{{ form_widget(form) }}
</div>
{{ form_end(form) }}

screen: 1

1 Answers1

2

In your case you have to choose the sonata_type_date_picker type in your form:

$datagridMapper
        ->add('startDate', 'sonata_type_date_picker')
        ->add('endDate', 'sonata_type_date_picker')
    ;

The documentation reference:

https://sonata-project.org/bundles/core/master/doc/reference/form_types.html

Sylvain Martin
  • 2,365
  • 3
  • 14
  • 29
  • thank you sir! followed instructions at https://sonata-project.org/bundles/core/master/doc/reference/form_types.html and it is working perfectly. – heyyouyayou Aug 06 '15 at 20:32