title: Symfony Form Submit not Working
body: <p>I've recently decided to take the plunge and learn Symfony as before I was learning flat PHP.</p>
  
  <p>I've been following various tutorials about how to add data to a database via a form in Symfony 3.  I have a MySQL table called CRM_PERSON and I'm trying to submit a person's details (a person is known as a "lead" in this project).  For some reason, when I press the submit button on the form, I simply get sent to a standard error page in Google Chrome saying "this site can't be reached.</p>
  
  <p>I've tried following the code exactly from three different tutorials now and various questions on Stack Overflow but I still can't seem to get this to work. I'm sure I must be doing something stupid here!</p>
  
  <p>Here is my code:</p>
  
  <p><strong>LeadController.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace AppBundle\Controller;
  
  use AppBundle\Form\CrmPersonType;
  use AppBundle\Entity\CrmPerson;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
  use Doctrine\ORM\EntityManagerInterface;
  
  
  
  
  class LeadController extends Controller
  {
      /**
       * @Route("/user/lead", name="lead")
       */
      public function indexAction(Request $request)
      {
  
          $leads = $this-&gt;getDoctrine()-&gt;getRepository('AppBundle:CrmPerson')-&gt;findAll();
  
          dump($leads);
  
          return $this-&gt;render(':lead:lead.html.twig', [
          'leads' =&gt; $leads
          ]);
       }
  
  
      /**
       * @Route("/user/lead_add", name="lead_add")
       */
      public function leadAdd(Request $request)   
      {
          $form = $this-&gt;createForm(CrmPersonType::class);
  
          $form-&gt;handleRequest($request);
  
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
  
              $em = $this-&gt;getDoctrine()-&gt;getManager();
  
              $crmperson = $form-&gt;getData();
  
              $em-&gt;persist($crmperson);
              $em-&gt;flush();
  
              return $this-&gt;redirectToRoute('lead_add');
          }
  
          return $this-&gt;render(':lead:lead.add.html.twig', [
          'leadForm' =&gt; $form-&gt;createView()
              ]);
      }
  
  
  
  }
  </code></pre>
  
  <p><strong>CrmPersonType.php</strong></p>
  
  <pre><code>&lt;?php
  
  // src/AppBundle/Form/CrmPersonType.php
  namespace AppBundle\Form;
  
  use AppBundle\Entity\CrmPerson;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\Extension\Core\Type\TextType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  
  class CrmPersonType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('title', TextType::class)
              -&gt;add('firstName', TextType::class) 
              -&gt;add('middleNames', TextType::class) 
              -&gt;add('surname', TextType::class)
              -&gt;add('submit', SubmitType::class, [
                  'label' =&gt; 'Save',
                  'attr'  =&gt; [
                      'class' =&gt; 'btn btn-success'
                  ]
              ])
          ;
      }
  
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults(array(
              'data_class' =&gt; CrmPerson::class,
          ));
      }
  }
  </code></pre>
  
  <p><strong>lead.add.html.twig</strong></p>
  
  <pre><code>{# app/Resources/views/lead.html.twig #}
  
  {% extends 'base.html.twig' %}
  
  {% block body %}
  
  &lt;html&gt;
      &lt;body&gt;
          &lt;div class="container-fluid"&gt;
          &lt;div class="panel panel-default"&gt;
          &lt;div class="panel-body"&gt;
              &lt;h1&gt;Add Lead&lt;/h1&gt;
  
              {{ form_start(leadForm) }}
              {{ form_widget(leadForm) }}
              {{ form_end(leadForm) }}
  
          &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  
  
  
      &lt;/body&gt;
  &lt;/html&gt;
  
  
  
  
  {% endblock %}
  </code></pre>
  
  <p>I'd be really grateful for some pointers in the right direction!</p>