Closed tpformybh closed 3 years ago
Describe the bug I have a crud controller where I'm using an AssociationField and trying to define the query builder:
yield AssociationField::new('lowLevelWarningUnitOfMeasure') ->setQueryBuilder( function(QueryBuilder $qb){ return $qb->andWhere('entity.isActive = true'); });
This works and only returns entities where isActive is true, however, rather than defining it in crud code I'm trying to use a repository method:
yield AssociationField::new('lowLevelWarningUnitOfMeasure') ->setQueryBuilder( function(QueryBuilder $qb){ return $qb->getEntityManager()->getRepository(UnitOfMeasure::class)->findAllActiveQueryBuilder(); });
the repository method is:
public function findAllActiveQueryBuilder() : QueryBuilder { return $this->createQueryBuilder('u') ->andWhere('u.isActive = :isActive') ->setParameter('isActive', true) ; }
This does not work, returning all active and non-active entities. The repository method is hit, and a dd placed in the repository method shows up.
dd
Why is this happening?
I wasn't passing in the query builder to the method to modify it, just returning a new one
Hello, i would be very interested in four final code if possible.
Describe the bug I have a crud controller where I'm using an AssociationField and trying to define the query builder:
This works and only returns entities where isActive is true, however, rather than defining it in crud code I'm trying to use a repository method:
the repository method is:
This does not work, returning all active and non-active entities. The repository method is hit, and a
dd
placed in the repository method shows up.Why is this happening?