Sonata Admin Bundle: DatePicker range

前端 未结 5 1984
长情又很酷
长情又很酷 2020-12-08 15:05

How would I create a doctrine_orm_datetime_range filter in the Sonata Admin Bundle which uses the jQuery UI datepicker?

I tried the following, but it do

5条回答
  •  半阙折子戏
    2020-12-08 15:44

    In Symfony 4 I had to do the following for datetime filter:

    # config/packages/twig.yml
    twig:
        form_themes:
            - '@SonataCore/Form/datepicker.html.twig'
    

    And in my admin class I had to configure the filter like this:

    use Sonata\CoreBundle\Form\Type\DateTimePickerType;
    
    ...
    
    protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
    {
        $datagridMapper->add('createdAt', 'doctrine_orm_datetime', [
            'field_type'=> DateTimePickerType::class,
        ]);
    }
    

提交回复
热议问题