title: Search function using twig in symfony
body: <p>I want to create a simple search function.</p>
  
  <p>Search form</p>
  
  <pre><code>&lt;form class="pull-right hidden" role="search" id="nav-search-form" method="post" action="{{ path('_search') }}"&gt;
          &lt;div class="input-group"&gt;
            &lt;input type="text" class="form-control" placeholder="Search" name ="search"&gt;
            &lt;span class="input-group-btn"&gt;
              &lt;button type="submit" class="btn btn-default"&gt;&lt;/button&gt;
            &lt;/span&gt;
          &lt;/div&gt;
        &lt;/form&gt;
  </code></pre>
  
  <p>In my DefaultController. I have a search function</p>
  
  <pre><code>public function searchAction(){
         $request = $this-&gt;getRequest();
         $data =$request-&gt;request-&gt;all();
  
  
         $em = $this-&gt;getDoctrine()-&gt;getManager();
         $query = $em-&gt;createQuery(
          'SELECT p.type, p.id
          FROM FooTransBundle:Trans p
          WHERE p.type LIKE :data')
         -&gt;setParameter('data',$data['search']);
  
  
      $res = $query-&gt;getResult();
  
      return $this-&gt;render('FooTransBundle:Default:search.html.twig', array(
          'res' =&gt; $res));
  </code></pre>
  
  <p>}</p>
  
  <p>And after I run that I got an error</p>
  
  <p>Notice: Undefined index: search in C:\xampp\htdocs\Sample\src\Foo\TransBundle\Controller\DefaultController.php line 96</p>
  
  <p>It is in the line ->setParameter('data',$data['search']); of my Controller</p>
  
  <p>Can someone help me. I am very new to symfony.
  Thanks for your help.</p>