I want to implement search form where users can search either by username or date.I created the form first: \[code\]form = $this->createFormBuilder() ->add ('username','text',array( 'required'=>false, 'label'=>'Search by username')) ->add ('date','date',array( 'input'=>'datetime', 'required'=>false, 'format'=>'yyyy-MM-dd', 'label'=>'Search by date')) ->getForm(); if ($request->getMethod() == 'POST') { $form->bind($request); if ($form->isValid()) { //and here i take the values from the form $user=$form["username"]->getData(); $data=http://stackoverflow.com/questions/15855102/$form["date"]->getData(); // and look for results in the database$em = $this->getDoctrine()->getManager();$query = $em->createQuery( 'SELECT b FROM AcmeWebBundle:baza b WHERE b.username = :user')->setParameter('user', $user);try { $users = $query->getResult(); }catch (\Doctrine\Orm\NoResultException $e) { return null ;}\[/code\]I have one query almost same which checks for the date instead for the username. When i try to send the results to twig template (code in addition), the variables are not found. The error is : Notice: Undefined variable: users in ...I have two questions: First how to fix the problem, and second, is this implementation good enough ? I know for Lucene plugin but i am trying to keep the code as simple as possible. Thank you guys.