title: Passing Entity to the createForm method in Symfony4
body: <p>When I am trying to create form and passing the Entity to the createForm method in symfony4 gives an exception as below. <code>An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class App\Entity\Email could not be converted to string").</code></p>
  
  <p>below is my code so far,</p>
  
  <h2>Controller code</h2>
  
  <pre><code>/**
       * @Route("/email/new", name="new_email")
       * Method({"GET","POST"})
       */
  
      public function new(Request $request)
      {
          $email = new Email();
  
  //        $email-&gt;setEmailAddress('fgesg');
  //        $email-&gt;setDeleted('0');
  
          $form = $this-&gt;createForm(EmailType::class, $email);
          return $this-&gt;render('main/new_email.html.twig',array(
              'form' =&gt; $form-&gt;createView()
          ));
      }
  </code></pre>
  
  <h2>Email.php - Entity</h2>
  
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity(repositoryClass="App\Repository\EmailRepository")
   */
  class Email
  {
      /**
       * @ORM\Id()
       * @ORM\GeneratedValue()
       * @ORM\Column(type="integer")
       */
      private $id;
  
      /**
       * @ORM\Column(type="text", nullable=true)
       */
      private $emailAddress;
  
      /**
       * @ORM\Column(type="integer", nullable=true)
       */
      private $deleted;
  
     //all getters and setters here
  }
  </code></pre>
  
  <h2>EmailType.php</h2>
  
  <pre><code>&lt;?php
  
  namespace App\Form;
  
  use App\Entity\Email;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  
  class EmailType extends AbstractType
  {
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('emailAddress')
              -&gt;add('deleted')
          ;
      }
  
      public function configureOptions(OptionsResolver $resolver)
      {
          $resolver-&gt;setDefaults([
              'data_class' =&gt; Email::class
          ]);
      }
  }
  </code></pre>
  
  <p>If the entity is not passed , It is creating the form but with one extra email text field. Anyway I want to show existing email data so I have to insert the email entity.</p>
  
  <p>Please help me on this.    </p>
  
  <p>----Edit--------
  below is the template new_email.html.twig</p>
  
  <pre><code>{% extends 'base.html.twig' %}
  
  {% block body %}
      {{ form_row(form.emailAddress) }}
      {{ form_row(form.deleted) }}
      {{ form_row(form.save) }}
  {% endblock %}
  {% block javascripts %}
      &lt;script type="text/javascript"&gt;
          $(function() {
              alert( "ready!" );
          });
      &lt;/script&gt;
  {% endblock %}
  </code></pre>