问题
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:
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
来源:https://stackoverflow.com/questions/31864883/sonata-admin-date-choice-wrapping