title: "Array to string covnersion" In entity type or choicetype symfony
body: <p>I have 2 entities, Sales and ProductsSales, in my ChoiceType I want to get data of my selected Productname, but in association of the id sale.</p>
  <p>There is my Sales entity :</p>
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use App\Repository\SalesRepository;
  use Doctrine\DBAL\Types\Types;
  use Doctrine\ORM\Mapping as ORM;
  
  #[ORM\Entity(repositoryClass: SalesRepository::class)]
  class Sales
  {
      #[ORM\Id]
      #[ORM\GeneratedValue]
      #[ORM\Column]
      private ?int $idsales = null;
  
      
  
      #[ORM\Column(type: Types::TEXT, nullable: true)]
      private ?string $NameSales = null;
  
      #[ORM\ManyToOne(inversedBy: 'idsales')]
      #[ORM\JoinColumn(nullable: false)]
      private ?ProductsSales $productsSales = null;
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getIdsales(): ?int
      {
          return $this-&gt;idsales;
      }
  
      public function setIdsales(int $idsales): self
      {
          $this-&gt;idsales = $idsales;
  
          return $this;
      }
  
      public function getNameSales(): ?string
      {
          return $this-&gt;NameSales;
      }
  
      public function setNameSales(?string $NameSales): self
      {
          $this-&gt;NameSales = $NameSales;
  
          return $this;
      }
  
      public function getProductsSales(): ?ProductsSales
      {
          return $this-&gt;productsSales;
      }
  
      public function setProductsSales(?ProductsSales $productsSales): self
      {
          $this-&gt;productsSales = $productsSales;
  
          return $this;
      }
  }
  
  </code></pre>
  <p>and  here the ProductsSales Entity</p>
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use App\Repository\ProductsSalesRepository;
  use Doctrine\Common\Collections\ArrayCollection;
  use Doctrine\Common\Collections\Collection;
  use Doctrine\ORM\Mapping as ORM;
  
  #[ORM\Entity(repositoryClass: ProductsSalesRepository::class)]
  class ProductsSales
  {
      #[ORM\Id]
      #[ORM\GeneratedValue]
      #[ORM\Column]
      private ?int $id = null;
  
      #[ORM\Column]
      private ?int $idproductsale = null;
  
      #[ORM\OneToMany(mappedBy: 'productsSales', targetEntity: Sales::class)]
      private Collection $idsales;
  
      public function __construct()
      {
          $this-&gt;idsales = new ArrayCollection();
      }
  
      public function getId(): ?int
      {
          return $this-&gt;id;
      }
  
      public function getIdproductsale(): ?int
      {
          return $this-&gt;idproductsale;
      }
  
      public function setIdproductsale(int $idproductsale): self
      {
          $this-&gt;idproductsale = $idproductsale;
  
          return $this;
      }
  
      /**
       * @return Collection&lt;int, Sales&gt;
       */
      public function getIdsales(): Collection
      {
          return $this-&gt;idsales;
      }
  
      public function addIdsale(Sales $idsale): self
      {
          if (!$this-&gt;idsales-&gt;contains($idsale)) {
              $this-&gt;idsales-&gt;add($idsale);
              $idsale-&gt;setProductsSales($this);
          }
  
          return $this;
      }
  
      public function removeIdsale(Sales $idsale): self
      {
          if ($this-&gt;idsales-&gt;removeElement($idsale)) {
              // set the owning side to null (unless already changed)
              if ($idsale-&gt;getProductsSales() === $this) {
                  $idsale-&gt;setProductsSales(null);
              }
          }
  
          return $this;
      }
  }
  
  </code></pre>
  <p>and there my salesType form :</p>
  <pre><code>$builder-&gt;add('ProductList', EntityType::class, [
      'class' =&gt; Sales::class,
      'choices' =&gt; $Sales-&gt;getNames(),
  ]);
  </code></pre>
  <p>and the the Sales controller</p>
  <pre><code>  public function CreateAction(Request $request){
  
      $form = $this-&gt;createForm(SalesType::class);
      $form-&gt;handleRequest($request);
  
     //logic of form hundling
      if (
        $form-&gt;isSubmitted()
        &amp;&amp; $form-&gt;isValid()
      )
      {
        //logic to store data
        $em = $this-&gt;getdoctrine()-&gt;getManager();
         dump($form-&gt;getdata());
         //die;
        $Sales = new Sales();
  
       //$Sales-&gt;SetProductList($form-&gt;get('ProductList')-&gt;getData());
  
  
        // stored to the db
        $em-&gt;persist($Sales);
        $em-&gt;flush();
          $this-&gt;addFlash
          (
              'Success',
              'Votre entrée a été ajoutée'
          );
  
          return $this-&gt;redirectToRoute('Sales_route_List');
     
      }
  
  
         return $this-&gt;render('@Modules/modulename/views/templates/admin/create.html.twig',['form' =&gt; $form-&gt;createView()]);
    }
  </code></pre>
  <p>when we send the form, There is a message of &quot;Array to string covnersion&quot;, an it's logical because i have an array in my entity type. The same problem for anothe Choicetype field, my need is simple need to detect the product name for each sale, and stock it as a string in my database !
  Any suggestion ??</p>