title: Bug Symfony Can use "yield from" only with arrays
body: <p>I'm creating a website with Symfony 5. I have a problem that I can't solve.
  I need to be able to create entities and for that I want to use a form generated by Symfony.</p>
  <p>Symfony sends me this error:</p>
  <p>Can use &quot;yield from&quot; only with arrays and Traversables
  If I modify anything in my &quot;Entities&quot; entity then symfony sends me back:</p>
  <p>My field I was waiting for</p>
  <p>Great, that's exactly what I need, but the problem is that if I refresh the page the error comes back.</p>
  <pre><code>&lt;?php 
  namespace App\Controller\Admin;
  
  use App\Entity\Entities;
  use App\Entity\Events;
  use App\Form\EntitiesType;
  use App\Form\EventsType;
  use App\Repository\CriteriasRepository;
  use App\Repository\EntitiesRepository;
  use App\Repository\EventsRepository;
  use Doctrine\Persistence\ObjectManager;
  use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  use Symfony\Component\HttpFoundation\Request;
  use Symfony\Component\HttpFoundation\Response;
  use Symfony\Component\Routing\Annotation\Route;
  
  
  Class AdminHome extends AbstractController {
  
      protected $event;
      protected $entity;
      protected $criteria;
      protected $twig;
  
      public function __construct(EventsRepository $event, EntitiesRepository $entity, CriteriasRepository $criteria, ObjectManager $em)
      {
          $this-&gt;event = $event;
          $this-&gt;entity = $entity;
          $this-&gt;criteria = $criteria;
          $this-&gt;em = $em;
      }
  
  
      public function index(){
  
          $event = $this-&gt;event-&gt;findOneBy(['current' =&gt; 1]);
          $criterias = $this-&gt;indexCriteria($event);
          $entities = $this-&gt;indexEntity($event);
  
          return new Response($this-&gt;render('admin/home.html',[ 'event' =&gt; $event, 'entities' =&gt; $entities, 'criterias' =&gt; $criterias ]));
      }
  
  
      public function indexEntity(Events  $event){
  
          return $event-&gt;getEntity();
      }
      
      public function indexCriteria(Events  $event){
          
          return  $event-&gt;getCriterias();
      }
  
      /**
       * @Route(&quot;/admin/event/create&quot;, name=&quot;admin.event.new&quot;)
       */
      public function newEvent(Request $request){
          $event = new Events();
          $form = $this-&gt;createForm(EventsType::class, $event);
          $form-&gt;handleRequest($request);
          if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()){
              $this-&gt;em-&gt;persist($event);
              $this-&gt;em-&gt;flush();
              return $this-&gt;redirectToRoute('adminHome');
          }
          return $this-&gt;render('admin/event/eventNew.html', ['event' =&gt; $event, 'form' =&gt; $form-&gt;createView()]);
      }
      
      /**
       * @Route(&quot;/admin/entity/create&quot;, name=&quot;admin.entity.new&quot;)
       */
      public function newEntity(Request $request){
          $entity = new Entities();
          $form = $this-&gt;createForm(EntitiesType::class, $entity);
          $form-&gt;handleRequest($request);
          if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()){
              $this-&gt;em-&gt;persist($entity);
              $this-&gt;em-&gt;flush();
              return $this-&gt;redirectToRoute('adminHome');
          }
          return $this-&gt;render('admin/entity/entityNew.html', ['entity' =&gt; $entity, 'form' =&gt; $form-&gt;createView()]);
  
      }
  
      // /**
      //  * @Route(&quot;/admin/entity/edit&quot;, name=&quot;admin.entity.edit&quot;)
      //  */
      // public function editEntity(Entities $entity, Request $request){
      //     $form = $this-&gt;createForm(EntityType::class, $entity);
      //     $form-&gt;handleRequest($request);
  
      //     if($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()){
      //         $this-&gt;em-&gt;flush();
      //         return $this-&gt;redirectToRoute('adminHome');
      //     }
      //     return $this-&gt;render('admin/entityEdit.html', ['entity' =&gt; $entity, 'form' =&gt; $form-&gt;createView()]);
      // }
  }
  ?&gt;
  
  </code></pre>
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  
  use Doctrine\Common\Collections\ArrayCollection;
  use Doctrine\Common\Collections\Collection;
  use Doctrine\ORM\Mapping as ORM;
  
  /**
  * @ORM\Entity(repositoryClass=EntitiesRepository::class)
  */
  class Entities
  {
     /**
      * @ORM\Id
      * @ORM\GeneratedValue
      * @ORM\Column(type=&quot;integer&quot;)
      */
     private $id;
  
     /**
      * @ORM\Column(type=&quot;string&quot;, length=255)
      */
     private $entityName;
  
     /**
      * @ORM\OneToMany(targetEntity=Rates::class, mappedBy=&quot;entity&quot;)
      */
     private $rates;
  
     /**
      * @ORM\ManyToMany(targetEntity=Events::class, mappedBy=&quot;entity&quot;)
      */
     private $event;
  
     /**
      * @ORM\Column(type=&quot;string&quot;, length=255)
      */
     private $descriptionFr;
  
     /**
      * @ORM\Column(type=&quot;string&quot;, length=255, nullable=true)
      */
     private $descriptionEn;
  
     /**
      * @ORM\ManyToMany(targetEntity=Themes::class, inversedBy=&quot;entities&quot;)
      */
     private $theme;
  
  
     public function __construct()
     {
         $this-&gt;rates = new ArrayCollection();
         $this-&gt;event = new ArrayCollection();
         $this-&gt;theme = new ArrayCollection();
     }
  
     public function getId(): ?int
     {
         return $this-&gt;id;
     }
  
     public function getEntityName(): ?string
     {
         return $this-&gt;entityName;
     }
  
     public function setEntityName(string $entityName): self
     {
         $this-&gt;entityName = $entityName;
  
         return $this;
     }
  
     /**
      * @return Collection|Rates[]
      */
     public function getRates(): Collection
     {
         return $this-&gt;rates;
     }
  
     public function addRate(Rates $rate): self
     {
         if (!$this-&gt;rates-&gt;contains($rate)) {
             $this-&gt;rates[] = $rate;
             $rate-&gt;setEntity($this);
         }
  
         return $this;
     }
  
     public function removeRate(Rates $rate): self
     {
         if ($this-&gt;rates-&gt;removeElement($rate)) {
             // set the owning side to null (unless already changed)
             if ($rate-&gt;getEntity() === $this) {
                 $rate-&gt;setEntity(null);
             }
         }
  
         return $this;
     }
  
     /**
      * @return Collection|Events[]
      */
     public function getEvent(): Collection
     {
         return $this-&gt;event;
     }
  
     public function addEvent(Events $event): self
     {
         if (!$this-&gt;event-&gt;contains($event)) {
             $this-&gt;event[] = $event;
             $event-&gt;addEntity($this);
         }
  
         return $this;
     }
  
     public function removeEvent(Events $event): self
     {
         if ($this-&gt;event-&gt;removeElement($event)) {
             $event-&gt;removeEntity($this);
         }
  
         return $this;
     }
  
     public function getDescriptionFr(): ?string
     {
         return $this-&gt;descriptionFr;
     }
  
     public function setDescriptionFr(string $descriptionFr): self
     {
         $this-&gt;descriptionFr = $descriptionFr;
  
         return $this;
     }
  
     public function getDescriptionEn(): ?string
     {
         return $this-&gt;descriptionEn;
     }
  
     public function setDescriptionEn(?string $descriptionEn): self
     {
         $this-&gt;descriptionEn = $descriptionEn;
  
         return $this;
     }
  
     /**
      * @return Collection|Themes[]
      */
     public function getTheme(): Collection
     {
         return $this-&gt;theme;
     }
  
     public function addTheme(Themes $theme): self
     {
         if (!$this-&gt;theme-&gt;contains($theme)) {
             $this-&gt;theme[] = $theme;
         }
  
         return $this;
     }
  
     public function removeTheme(Themes $theme): self
     {
         $this-&gt;theme-&gt;removeElement($theme);
  
         return $this;
     }
  
  
  }
  
  </code></pre>
  <pre><code>&lt;?php
  
  namespace App\Form;
  
  use App\Entity\Entities;
  use Symfony\Component\Form\AbstractType;
  use Symfony\Component\Form\FormBuilderInterface;
  use Symfony\Component\OptionsResolver\OptionsResolver;
  
  class EntitiesType extends AbstractType
  {
     public function buildForm(FormBuilderInterface $builder, array $options)
     {
         $builder
             -&gt;add('entityName')
             -&gt;add('descriptionFr' )
             -&gt;add('descriptionEn')
             -&gt;add('event')
             -&gt;add('theme')
         ;
     }
  
     public function configureOptions(OptionsResolver $resolver)
     {
         $resolver-&gt;setDefaults([
             'data_class' =&gt; Entities::class,
         ]);
     }
  }
  </code></pre>
  <pre><code>{{ form_start(form) }}
      {{ form_rest(form) }}
      &lt;button class=&quot;btn&quot;&gt;{{ button|default('Créer')}}&lt;/button&gt;
  {{ form_end(form) }}
  
  
  </code></pre>