I\'m trying to generate a form type in particular the \"ProductLanguageType\".
I want to generate the ProductLanguageType as many times as the current numbers of exi
Now in Symfony 3.0 they changed the createNamedBuilder, so it's possible to solve this by only calling:
use AppBundle\Form\ShippingTrackCodeReturnType;
$uniqueForm = $this->get('form.factory')->createNamedBuilder('ship_form_'.$orderRecord->getId(), ShippingTrackCodeReturnType::class, $orderRecord)->getForm();
So, you just need to loop to display and save them:
foreach ($invoice->getOrderRecords() as $key => $orderRecord)
{
// creates the forms with different names
$returnShipTrackCodeForm = $this->get('form.factory')->createNamedBuilder('ship_form_'.$orderRecord->getId(), ShippingTrackCodeReturnType::class, $orderRecord)->getForm();
$returnShipTrackCodeForm->handleRequest($request);
if ($returnShipTrackCodeForm->isSubmitted() && $returnShipTrackCodeForm->isValid())
{
// flush object
}
$returnForms[$orderRecord->getId()] = $returnShipTrackCodeForm;
}