goncziakos/datetimerange-filter-bundle

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

DateTimeRangeType Datagrid Filter for Sonata Admin MongoDB

v2.0.0 2020-08-06 13:41 UTC

This package is not auto-updated.

Last update: 2021-09-16 17:50:28 UTC


README

DateTimeRangeType Datagrid Filter for Sonata Admin MongoDB

Installation

$ composer require goncziakos/datetimerange-filter-bundle

Symfony 3.4:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        // ...
        new GoncziAkos\DateTimeRangeFilterBundle\GoncziAkosDateTimeRangeFilterBundle(),
    ];
}

Symfony 4.x:

<?php
// config/bundles.php

return [
    GoncziAkos\DateTimeRangeFilterBundle\GoncziAkosDateTimeRangeFilterBundle::class => ['all' => true],
];

Usage

Format optional filter option.

<?php

// ...
use Sonata\AdminBundle\Admin\AbstractAdmin;
use GoncziAkos\DateTimeRangeFilterBundle\Form\Type\Filter\DateTimeRangeType;
// ...

class XYAdmin extends AbstractType
{
    $datagridMapper
        ->add('createdAt', DateTimeRangeType::class)
    ;

Format optional filter option.

    $datagridMapper
        ->add('createdAt', DateTimeRangeType::class, [
            'format' => 'yyyy-MM-dd HH:mm'
        ])
    ;

License

This bundle is released under the LGPL license.