I'm trying to implement subforms to allow for adding/removing multiple 
instances of a oneToMany relation. 

I have it working for a single instance but how do I go about being able to 
process multiple fields that are added with jquery?
I'm used to doing this using array notation so some help with the Symfony2 
way would be much appreciated. 

Here's my code so far:

<?php
namespace Sensio\MsmBundle\Form;

use Symfony\Component\Form\Form;
use Symfony\Component\Form\TextField;
use Sensio\MsmBundle\Form\ServiceForm;

class EstimateForm extends Form
{
 public function configure()
 {
    $this->addOption('em');
    $em = $this->getOption('em');
      
    $this->setDataClass("Sensio\MsmBundle\Entity\Estimate");

    $serviceRepository = 
$em->getRepository('Sensio\MsmBundle\Entity\Service');

    $this->add(new TextField('number'));
    $this->add(new TextField('date'));

    //embed services form
    $this->add(ServiceForm::create($this->getContext(), 'services', 
array('em' => $em)));
  }
}

//form.html.twig-------------------
<form id="estimateForm" action="#" method="post" {{ 
form_enctype(estimateForm) }} >
{{ form_field(form.number) }}
{{ form_field(form.date) }}
{{ form_field(form.services) }}
{{ form_hidden(form) }}
</form>


Thanks.

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to