handle which form is submitted and persist entity after findAll
<p>I'll try to explain myself (my English is not as good as I wish)</p>
<ul>
<li>I'm very inexperienced with symfony2 and doctrine2.</li>
<li>I'm trying to create a twig template and all the logic to handle modifications in, for example, user entity.</li>
<li>I've made the UserType AbstractType class and can handle, modify and persist if I get just one record or, at least, if I show only one form.</li>
<li>I've tried to do the same thing showing to the user every &quot;User&quot; in my database, and allowing him to modify and save one of them each time by clicking in submit button.</li>
</ul>
<hr />
<h3>What I have right now:</h3>
<p><em>src/Dummy/Form/Type/UserType.php</em></p>
<pre><code>namespace Dummy\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;

class UserType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            -&gt;setAction('')
            -&gt;setMethod('POST')
            -&gt;add('Name')
            -&gt;add('Adress')
            -&gt;add('save')
        ;
    }
}
</code></pre>
<p><em>src/Dummy/Test/Controller/TestController.php</em></p>
<pre><code>namespace Dummy\TestBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;

use Dummy\TestBundle\Entity\Users;

use Dummy\Form\Type\UserType;

class ArticuloController extends Controller
{
    public function indexAction(Request $request)
    {
        //some stuff
        $users= $this-&gt;getDoctrine()
            -&gt;getRepository('DummyTestBundle:Users')
            -&gt;findAll();
        $forms = array();
        foreach($users as $user)
        {
            $forms[] = $this-&gt;createForm(UserType::class, $user); //*1
        }

       //... Don't know how to handle request with $forms[index]-&gt;submit(...
       //... Check if is valid
       //... set values
       //... persist

       $twigForms = array();
       foreach($forms as $form)
       {
          $twigForms[] = $form-&gt;createView()
       }

       //... render twig template 
    }
}
</code></pre>
<p>Also I have the entity Users which works fine, made from yaml config file as described in the documentation</p>
<h3>What I want</h3>
<p>Handle the request and persist the object modifications.</p>
<h3>The part that works</h3>
<p>Until clicking in that submit button this works fine, it shows a template with a form for each user in database, every one of them with his submit button. After pressing any of them I'm completely lost.</p>
<p>If I force index to be 0, it works too (but only in the first form).</p>
<p>Because of that, I think that I need to know the index in $users or $forms variable (marked with *1 commented point above) in order to handle that request using something like:</p>
<pre><code>$forms[index]-&gt;submit($request-&gt;request-&gt;get($forms[index]-&gt;getName()));
if ($forms[index]-&gt;isValid()) {
    $users[index]-&gt;setName('Name from post');
    $users[index]-&gt;setAdress('Adress from post');
    $em = $this-&gt;getDoctrine()-&gt;getManager();
    $em-&gt;persist($users[index]);
    $em-&gt;flush();
}
</code></pre>
<p>But don't know if this is correct or how to do it.
I also read about collections, but don't know how to make this work with them.</p>