0

I'm write a simple code in sonata admin with createQuery() for configureListFields().

When I write groupby , I get the following error:

The query returned multiple rows. Change the query or use a different result function like getScalarResult().

public function createQuery($context = 'list')
{
    $query = parent::createQuery($context);
    $rootAlias = $query->getRootAliases()[0];
    $query->groupby($rootAlias.'.cityId');

    return $query;
}
Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130
Pavel
  • 155
  • 1
  • 7

1 Answers1

2

You have to use "simple" pager, like explained here due to a bug in the default paginator.

https://stackoverflow.com/a/48803077/7135824

In service.yaml

tags:
    - { name: sonata.admin, pager_type: "simple", ...
ste
  • 1,479
  • 10
  • 19