title: Symfony2.8 how to build a search form that will be viewable from all templates
body: <p>What would be the best way to build a search form that i would render in my base twig template so it could be always visible?</p>
  
  <p>I created a form type class according to my needs and can use it in a controller
  and then render the form on a template but it makes no sense to do the same for the other controllers and templates so i wrote a service:</p>
  
  <pre><code>&lt;?php
  
  namespace MyBundle\Services;
  
  use Symfony\Component\Form\FormFactory;
  
  use MyBundle\Form\FulltextSearchType;
  
  class FulltextSearch {
  
      private $formFactory;
  
      public function __construct(FormFactory $formFactory) {
          $this-&gt;formFactory = $formFactory;
      }
  
      public function mySearch() {
          $form = $this-&gt;formFactory-&gt;createBuilder('MyBundle\Form\FulltextSearchType');
  
          return $form-&gt;getForm()-&gt;createView();
          //return $form-&gt;createView();
      }
  
  }
  </code></pre>
  
  <p>i also defined the service in the services.yml and config.yml and i render that in my template:</p>
  
  <pre><code>&lt;form action="{{ path('my_search') }}" method="post"&gt;    
      {{ form_widget(fulltextSearch.mySearch) }}
  &lt;/form&gt;
  </code></pre>
  
  <p>It works, i get the form, i get the request after form submission but i doubt that this is the best way to achieve what my question title says</p>