title: Object provided to Escape helper, but flags do not allow recursion in Zend Framework 2
body: <p>So i work in a <strong>Zend Framework</strong> project and i am using <strong>Doctrine</strong>, i create my Form, Controller and Entities, but when i run my project i got this error :</p>
  
  <pre><code>Object provided to Escape helper, but flags do not allow recursion
  </code></pre>
  
  <p><strong>This is my Entity :</strong></p>
  
  <pre><code>namespace Application\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Zend\Form\Annotation;
  
  /**
   * Article
   *
   * @ORM\Table()
   * @ORM\Entity(repositoryClass="Application\Entity\ArticleRepository")
   */
  class Article
  {   
      /**
       * @ORM\Column(name="publication", type="boolean")
       */
      private $publication;
  
      public function __construct()
      {
          $this-&gt;date = new \Datetime();
      }
      /**
       * @var integer
       *
       * @ORM\Column(name="id", type="integer")
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @var string
       *
       * @ORM\Column(name="title", type="string", length=255)
       */
      private $title;
  
      /**
       * @var \DateTime
       *
       * @ORM\Column(name="date", type="date")
       */
      private $date;
  
      /**
       * @var string
       *
       * @ORM\Column(name="content", type="text")
       */
      private $content;
  
      /**
       * @ORM\OneToOne(targetEntity="Application\Entity\Image", cascade={"persist","remove"})
       */
      private $image;
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set title
       *
       * @param string $title
       * @return Article
       */
      public function setTitle($title)
      {
          $this-&gt;title = $title;
  
          return $this;
      }
  
      /**
       * Get title
       *
       * @return string 
       */
      public function getTitle()
      {
          return $this-&gt;title;
      }
  
      /**
       * Set date
       *
       * @param \DateTime $date
       * @return Article
       */
      public function setDate($date)
      {
          $this-&gt;date = $date;
  
          return $this;
      }
  
      /**
       * Get date
       *
       * @return \DateTime 
       */
      public function getDate()
      {
          return $this-&gt;date;
      }
  
      /**
       * Set content
       *
       * @param string $content
       * @return Article
       */
      public function setContent($content)
      {
          $this-&gt;content = $content;
  
          return $this;
      }
  
      /**
       * Get content
       *
       * @return string 
       */
      public function getContent()
      {
          return $this-&gt;content;
      }
  
      /**
       * Set publication
       *
       * @param boolean $publication
       * @return Article
       */
      public function setPublication($publication)
      {
          $this-&gt;publication = $publication;
  
          return $this;
      }
  
      /**
       * Get publication
       *
       * @return boolean 
       */
      public function getPublication()
      {
          return $this-&gt;publication;
      }
  
      /**
       * Set image
       *
       * @param \Application\Entity\Image $image
       * @return Article
       */
      public function setImage(\Application\Entity\Image $image = null)
      {
          $this-&gt;image = $image;
  
          return $this;
      }
  
      /**
       * Get image
       *
       * @return \Application\Entity\Image 
       */
      public function getImage()
      {
          return $this-&gt;image;
      }
  
  }
  </code></pre>
  
  <p><strong>And this is Form with fields validation:</strong></p>
  
  <pre><code>class ArticleForm extends Form implements ObjectManagerAwareInterface
  
  {
      /**
       * @var EntityManager
       */
      protected $em;
  
      public function init()
      {
          $this-&gt;add(array(
                  'name' =&gt; 'title',
                  'attributes' =&gt; array(
                          'type' =&gt; 'text',
                  ),
                  'options' =&gt; array(
                          'label' =&gt; 'Title'
                  ),
          ));
  
          $this-&gt;add(array(
              'name' =&gt; 'id',
              'attributes' =&gt; array(
                  'type'  =&gt; 'hidden',
              ),
          ));
  
          $this-&gt;add(array(
                  'name' =&gt; 'content',
                  'attributes' =&gt; array(
                          'type' =&gt; 'textera',
                  ),
                  'options' =&gt; array(
                          'label' =&gt; 'Content'
                  ),
          ));
  
          $this-&gt;add(array(
                  'name' =&gt; 'date',
                  'attributes' =&gt; array(
                          'type' =&gt; 'text',
                          'class' =&gt; 'datepicker',
                  ),
                  'options' =&gt; array(
                          'label' =&gt; 'Date',
                  ),
          ));
  
  
          $this-&gt;add(array(
                  'name' =&gt; 'publication',
                  'attributes' =&gt; array(
                          'type' =&gt; 'Checkbox',
                  ),
          ));
  
          $this-&gt;add(array(
                  'name' =&gt; 'url',
                  'attributes' =&gt; array(
                          'type' =&gt; 'file',
                          'id'   =&gt; 'files',
                          'class'=&gt; 'upload'  
                  ),
                  'options' =&gt; array(
                          'label' =&gt; 'Url'
                  ),
          ));
  
          $this-&gt;add(array(
                  'name' =&gt; 'alt',
                  'attributes' =&gt; array(
                          'type' =&gt; 'text',
                  ),
                  'options' =&gt; array(
                          'label' =&gt; 'Alt'
                  ),
          ));
  
          $this-&gt;add(array(
              'name' =&gt; 'submit',
              'attributes' =&gt; array(
                  'type'  =&gt; 'submit',
                  'value' =&gt; 'Go',
                  'class' =&gt; 'submit',
              ),
          ));
  
          $this-&gt;setInputFilter($this-&gt;createInputFilter());
      }
  
      public function __construct($name = null, $options = array())
      {         
          parent::__construct($name, $options);
      }
  
      public function createInputFilter()
      {
      if (!$this-&gt;inputFilter) {
              $inputFilter = new InputFilter();
              $factory     = new InputFactory();
  
              $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name'     =&gt; 'title',
                      'required' =&gt; true,
                      'filters'  =&gt; array(
                              array('name' =&gt; 'StripTags'),
                              array('name' =&gt; 'StringTrim'),
                      ),
                      'validators' =&gt; array(
                              array(
                                      'name'    =&gt; 'StringLength',
                                      'options' =&gt; array(
                                              'encoding' =&gt; 'UTF-8',
                                              'min'      =&gt; 6,
                                              'max'      =&gt; 100,
                                      ),
                              ),
                      ),
              )));
  
              $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name'     =&gt; 'content',
                      'required' =&gt; true,
                      'filters'  =&gt; array(
                              array('name' =&gt; 'StripTags'),
                              array('name' =&gt; 'StringTrim'),
                      ),
                      'validators' =&gt; array(
                              array(
                                      'name'    =&gt; 'StringLength',
                                      'options' =&gt; array(
                                              'encoding' =&gt; 'UTF-8',
                                              'min'      =&gt; 10,
                                      ),
                              ),
                      ),
              )));
  
              $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name'     =&gt; 'publication',
                      'required' =&gt; false,
              )));
  
              $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name'     =&gt; 'date',
                      'required' =&gt; true,
              )));
  
              $inputFilter-&gt;add($factory-&gt;createInput(array(
                      'name'     =&gt; 'image',
                      'required' =&gt; true,
              )));
  
              $this-&gt;inputFilter = $inputFilter;
          }
  
          return $this-&gt;inputFilter;
      }
  
      public function setObjectManager(ObjectManager $objectManager) {
          $this-&gt;objectManager = $objectManager;
      }
  
      /**
       * Get the object manager
       *
       * @return ObjectManager
       */
      public function getObjectManager() {
          return $this-&gt;objectManager;
      }
  
  }
  </code></pre>
  
  <p><strong>Then my Action :</strong></p>
  
  <pre><code>public function addAction()
  {       
      $form = new ArticleForm($this-&gt;getObjectManager());
      $article = new Article();
      $request = $this-&gt;getRequest();
      $hydrator = new DoctrineHydrator($this-&gt;getObjectManager(), get_class($article));
      $form-&gt;setHydrator($hydrator);
      $form-&gt;bind($article);
      if ($this-&gt;zfcUserAuthentication()-&gt;hasIdentity()) {
          if ($request-&gt;isPost()) 
          {
              $form-&gt;setData($request-&gt;getPost());
              if ($form-&gt;isValid()) {
                  $this-&gt;getObjectManager()-&gt;persist($article);
                      $this-&gt;getObjectManager()-&gt;flush();
  
                      return $this-&gt;redirect()-&gt;toRoute('blog');
              }
               }
      }
      else
      {
          return $this-&gt;redirect()-&gt;toRoute('user');
      }
      return array('form' =&gt; $form);
  }
  </code></pre>
  
  <p><strong>Finally my View where i think i have an error :</strong></p>
  
  <pre><code> &lt;?php 
     $form = $this-&gt;form;
     $form-&gt;setAttribute('action', $this-&gt;url('add', array('action' =&gt; 'add')));
     $form-&gt;prepare();
   ?&gt;
   &lt;?php  
     echo $this-&gt;form()-&gt;openTag($form);
   ?&gt;
   &lt;ul&gt;
      &lt;li&gt;
          &lt;?php echo $this-&gt;formHidden($form-&gt;get('id'));?&gt;
      &lt;li&gt;
      &lt;li&gt;
          &lt;label&gt;Publication:&lt;/label&gt;
          &lt;?php echo $this-&gt;formInput($form-&gt;get('publication'));?&gt;
      &lt;/li&gt;
      &lt;li&gt;
          &lt;label&gt;Title:&lt;/label&gt;
          &lt;?php echo $this-&gt;formInput($form-&gt;get('title'));?&gt;
      &lt;/li&gt;
           // ....
      &lt;li&gt;
          &lt;?php echo $this-&gt;formSubmit($form-&gt;get('submit'));?&gt;&lt;/li&gt;
      &lt;/ul&gt;
  &lt;?php
      echo $this-&gt;form()-&gt;closeTag();
  ?&gt;
  </code></pre>
  
  <p>That it's, this is almost my codes, i tried everything and i didn't found any solution, and i think the error in my view, so please if someone has any idea i will be very appreciative </p>