【发布时间】:2026-01-26 00:05:02
【问题描述】:
我的实体中有:
/**
* @ORM\ManyToMany(targetEntity="Sancho\UserBundle\Entity\followers", mappedBy="followers")
*/
private $followers;
在奏鸣曲中,我想获得 $followers[] 的数量。我在我的实体中创建:
public function getFollow()
{
return count($this->followers);
}
在 UserAdmin 我有:
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('id')
->add('follow', null, array('sortable'=>true));
}
我有 $follow[] 的数量,但我无法对该字段进行排序。当我排序时出现错误:
PHP Catchable fatal error: Argument 1 passed to Sonata\\DoctrineORMAdminBundle\\Datagrid\\ProxyQuery::entityJoin() must be of the type array, null given, called in /home/sancho/work/Web/vendor/sonata-project/doctrine-orm-admin-bundle/Datagrid/ProxyQuery.php on line 140 and defined in /home/sancho/work/Web/vendor/sonata-project/doctrine-orm-admin-bundle/Datagrid/ProxyQuery.php on line 245
【问题讨论】:
标签: php symfony sonata-admin symfony-sonata