title: persist each text field in a separate row
body: <p>i have the following code , i believe that this is not the right way to do what im trying to do..</p>
  
  <p>here is what i want to accomplish </p>
  
  <p>i have a page to add a new language key and the translation for that key .
  the translation text-boxes are dynamic (coming from the language table) .
  the name of each text field is the locale for that language (which is also stored in the language table) and i use it to get the language id (which is linked in the translation table)</p>
  
  <h2>here is my database tables</h2>
  
  <h2>language</h2>
  
  <p>id (AI)     --------> languageid</p>
  
  <p>locale</p>
  
  <p>languageName</p>
  
  <hr>
  
  <h2>translation</h2>
  
  <p>id (AI)</p>
  
  <p>languageid</p>
  
  <p>languagekey</p>
  
  <p>translation</p>
  
  <hr>
  
  <p>so from the language table i get the list of text boxes that should be there and loop though them</p>
  
  <p>and when the user hits save i use the following way  to save what he entered</p>
  
  <pre><code>   if ($form-&gt;isValid()) {
        print_r($form-&gt;getData()); // debug
  
        foreach($form-&gt;getData() as $key =&gt; $value){ // get the submitted data
          $oTranslation = new Translations(); // creat a new entity object 
          if($key == 'languageKey'){ // if it was the language key text field
            $languageKey = $value;
            continue;
          }
          $locale = $key; // the locale to extract the language id later on
          $translation = $value;
          //----- start getting the language id
          $language = $this-&gt;getDoctrine()
                      -&gt;getRepository('CodeizSDBTranslatorBundle:Languages');
          $query = $language-&gt;createQueryBuilder('l')
                             -&gt;select('l.id')
                             -&gt;where('l.locale = :locale')
                             -&gt;setParameter('locale' , $locale)
                             -&gt;getQuery();
          $id = $query-&gt;getResult();
          //----- end getting the language id
  
          $oTranslation-&gt;setLanguageId($id[0]['id']); // setting the vlaues
                       $oTranslation-&gt;setLanguageKey($languageKey);
                       $oTranslation-&gt;setTranslation($translation);
                    $em = $this-&gt;getDoctrine()-&gt;getManager();
        $em-&gt;persist($oTranslation); 
        $em-&gt;flush();// getting them into the database
        }
  
  
        return $this-&gt;redirect($this-&gt;generateUrl('codeiz_sdb_translator_addlanguagekey')); // redirect to some place
    }
  </code></pre>
  
  <p>i know what i did get's the job done but  here is my question ..</p>
  
  <p>is they way im saving the data to the DB correct or is there a better way ..</p>