I am creating a Form form Policy where i want show those vehicles are not already used or associated with policy since its a one to one relation ship, and i am using query_builder for this purpose but i am not getting filtered results.
$form = $this->createFormBuilder($policy)
->add('vehicle', EntityType::class,[
'class'=>Vehicle::class,
'label' => 'Vehicle Plate',
'query_builder' => function (VehicleRepository $vr){
return $vr->createQueryBuilder('vehicle')
->andWhere('vehicle.policy IS NULL');
}])
But i am getting this error
A single-valued association path expression to an inverse side is not supported in DQL queries. Instead of "vehicle.policy" use an explicit join.