I haven't played enough with symfony2 to get you a definitive answer, but
here are some ways you could look first:

from my understanding, the form framework in sf2 stayed mostly the same as
the sf 1.4 form framework. In this case you could have a look at the code of
this plugin: sfDoctrineDynamicFormRelationsPlugin

which does exactly what you're trying to do, though on the previous version
of symfony. Maybe you can find something there




On Wed, Feb 23, 2011 at 4:55 PM, jdewit <[email protected]>wrote:

> 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
>

-- 
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