Multiple filter in sonata admin
Asked Answered
F

1

6

I want to have that a filtered field in sonata admin datagrid mapper can be OR or AND connected with the user given filter values ... for example the field "Name" can be "John" or "Sandy" ... In the docs on https://sonata-project.org/bundles/doctrine-orm-admin/master/doc/reference/filter_field_definition.html they write

 ->add('tags', null, array(), null, array('expanded' => true, 'multiple' => true))

where i aspect, that the keword "multiple" should allow a field to be added multiple times ... but all i get is, that "multiple" and "expanded" is not a valid option for this field.

How can i let the user filter by AND or OR conditions?

Thanks

Finbar answered 11/12, 2017 at 11:9 Comment(1)
expanded and multiple are options for drop-down lists, 1st makes it always open, 2nd lets you select multiple values - not what you want.Halle
M
1

In Sonata 4.x, an exemple of working code

protected function configureDatagridFilters(DatagridMapper $filter): void
{
    /* ... */
    $filter
        ->add('tags', null, [
            'field_options' => [
                'multiple'  =>  true,
            ]
        ]);
}
Melia answered 10/2, 2023 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.