Sonata Admin date choice wrapping

丶灬走出姿态 提交于 2019-12-13 02:24:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!