title: Symfony build form text fields with data from array
body: <p>In Symfony I need to create a form with text fields that would hold data pulled from the database for editing. At the moment I have this code where I am getting a question with it's four answers:</p>
  
  <pre><code>$question = $this-&gt;getDoctrine()-&gt;getRepository('QuizBundle:Question')-&gt;findOneByIdJoinedToCategory($id);
  $data = $question-&gt;getAnswers();
  </code></pre>
  
  <p>This retrives the question and the answers which are stored in an Array Collection.
  At the moment I can build the form with the question data, but how can I use the answers from the Array Collection to build text fields with the data? 
  I can also convert the array collection to a regular array, if so how to build text fields with data from a regular array? 
  Thanks</p>
  
  <p><strong>Form Builder:</strong></p>
  
  <pre><code>$form = $this-&gt;createFormBuilder($question)
              -&gt;add('Image', TextType::class)
              -&gt;add('Question', TextType::class)
              -&gt;add('answers', TextType::class,
                     array('data' =&gt; array()))
              -&gt;add('Submit',SubmitType::class, array('label' =&gt; 'Edit Record'))
          -&gt;getForm();
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/YKzzs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YKzzs.jpg" alt="enter image description here"></a></p>