I am looking for to display some dates in a field embedded to a form. In fact, the fields is correct when I passed my query in the repository and display it with the twig template. But when I get the same query and embed in the form, an exception is coming...
May be, I have a problem because it's date.
The field in my Form :
->add('dateEnd', 'entity', array(
'class' => 'BackBundle:PackagesDatesPrices',
'property' => 'DateEnd',
'query_builder' => function(EntityRepository $er) use ($id) {
return $er->createQueryBuilder('a')
->innerjoin('a.package', 'c', 'WITH', 'a.package = c.id')
->addSelect('a')
->add('where', 'c.id = :id')
->add('orderBy', 'a.price ASC')
->setParameter('id', $id)
;
},
))
In my repository :
public function getAdvertWithDatesPrices($id)
{
$qb = $this->createQueryBuilder('a')
->innerjoin('a.package', 'c', 'WITH', 'a.package = c.id')
->addSelect('a')
->add('where', 'c.id = ?1')
->add('orderBy', 'a.price ASC')
->setParameter(1, $id);
;
return $qb
->getQuery()
->getResult()
;
}
Thank you for your advices.