title: Symfony 2 : Save json and display value
body: <p>I'm actually developping a personal project with Symfony2.
  And i want to to do something but i don't know how to do that.
  I have an entity <code>Recette</code> and in this entity i have a property <code>ingredients</code>
  This ingredients property is a <code>json_array</code> type.</p>
  
  <pre><code>&lt;?php
  
  namespace sf2\RecetteBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Recette
   *
   * @ORM\Table()
   * @ORM\Entity(repositoryClass="sf2\RecetteBundle\Entity\RecetteRepository")
   */
  class Recette
  {
      // ...
  
      /**
       * @var array
       *
       * @ORM\Column(name="ingredients", type="json_array")
       */
      private $ingredients;
  
     // ...
  }
  
  ?&gt;
  </code></pre>
  
  <p>In this <code>json_array</code> i just want to save a couple of information.
  Ex : </p>
  
  <pre><code>["name":"potatoes","quantity":"5kg"]
  </code></pre>
  
  <p>Here you can find my Entity FormType : </p>
  
  <pre><code>class RecetteType extends AbstractType
  {
      /**
      * @param FormBuilderInterface $builder
      * @param array $options
      */
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('name','text',array('label' =&gt; "test","attr"=&gt;array('class'=&gt;'test')))
              -&gt;add('completionTime')
              -&gt;add('ingredients',
                  'collection',
                  array(
                      'type'=&gt;'text',
                      'prototype'=&gt;true,
                      'allow_add'=&gt;true,
                      'allow_delete'=&gt;true,
                      'options'=&gt;array(
                      )
                  )
              )
              -&gt;add('preparation')
              -&gt;add('recetteCategories')
              -&gt;add('Ok','submit')
          ;
      }
  }
  </code></pre>
  
  <p>In my form i can add with jquery with any problem add an ingredient, but my problem is that i can't save the quantity information. i don't know how to display in my form two field instead one for an ingredient.</p>
  
  <p>Currently when i save an ingredient i have this data in database : </p>
  
  <pre><code>["Potatoes"]
  </code></pre>
  
  <p>How i can display in my form two fields for an ingredient and how to save it in this format ?</p>
  
  <pre><code>["name":"potatoes","quantity":"5kg"]
  </code></pre>
  
  <p>Thanks.</p>