-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createIndexQueryBuilder fails with "Cannot read property "id" from an array. .... #5692
Comments
The problem is that the query builder returns an array as a result, but for EasyAdmin it must be an object list. I have the same issue now and I don't know how to force query builder cast array to some object. |
Did anyone find a solution? |
Come here cause I got the same issue but figure out the solution. You need to use the keyword Example: $queryBuilder->addSelect('SUM(case when s.assignedAt IS NULL then 1 else 0 end) AS HIDDEN free'); This does not alter your database query so you can order your query by this column without any issue for example. You can see a working example in official documentation : https://symfony.com/bundles/EasyAdminBundle/current/fields.html#unmapped-fields |
TextField::new('fullName') |
I tested it in Symfony 6.4 and had no issue. Could you add a more detailed example ? What return null exactly ? The error resolved with the keyword |
I have the same problem. SQL query is built correctly and is executed successfully, but the field value is not transferred to EasyAdmin. Symfony 6.1, Doctrine 2.14.3 |
I solved it by calling a new repository function where i select all existing fields, including the custom ones. But I would also be interested to know if there is a shorter way. |
Same problem. Looks like a bug, right? |
In my crud controller i use the createIndexQueryBuilder method to additionally add a calculated value to the result.
public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder
{
$queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters);
$queryBuilder->addSelect('SUM(case when s.assignedAt IS NULL then 1 else 0 end) AS free');
$queryBuilder->leftJoin('entity.serials','s');
$queryBuilder->groupBy('entity.id');
return $queryBuilder;
}
In frontend ist shows the following error:
Cannot read property "id" from an array. Maybe you intended to write the property path as "[id]" instead.
NoSuchPropertyException
Any idea?
The text was updated successfully, but these errors were encountered: