Hi there!

Take a look at this example:
https://github.com/beberlei/AcmePizzaBundle/blob/master/Resources/views/Order/index.html.twig#L70

Basically, you should just iterate over addresses.

There'll ultimately be a cookbook article around this situation, but it's
not finished yet.

Thanks!

Ryan Weaver
US Office Head & Trainer - KnpLabs - Nashville, TN
http://www.knplabs.com <http://www.knplabs.com/en>
http://www.thatsquality.com
Twitter: @weaverryan


On Fri, May 6, 2011 at 3:53 AM, barbacan <julien.ga...@gmail.com> wrote:

> (I originally posted my question here :
>
> http://stackoverflow.com/questions/5894570/how-to-deal-with-form-collection-on-symfony2-beta
> ?)
>
>
> Hi!
>
> I have an entity User and an entity Address. There is a relation One-
> to-Many between User and Address :
>
>    class User
>    {
>        /**
>        * @orm:OneToMany(targetEntity="Address")
>        */
>        protected $adresses;
>
>        [...]
>
>    }
> I have a class AddressType, and class UserType :
>
>    class UserType extends AbstractType
>    {
>        public function buildForm(FormBuilder $builder, array
> $options)
>        {
>            $builder->add('addresses', 'collection', array('type' =>
> new AddressType()));
>
>        }
>
>        [...]
>    }
> In my controller, I build form with :
>
>    $form = $this->get('form.factory')->create(new UserType());
> ... and create view with :
>
>    return array('form' => $form->createView());
> I display form field in my twig template with :
>
>    {{ form_errors(form.name) }}
>    {{ form_label(form.name) }}
>    {{ form_widget(form.name) }}
>    [...]
> Okay. Now, how to display fields for one or more addresses ? (it's no
> {{ for_widget(form.adresses.zipcode) }} nor
> {{ for_widget(form.adresses[0].zipcode) }} ...)
>
> Any ideas ?
>
> --
> 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 symfony-users@googlegroups.com
> To unsubscribe from this group, send email to
> symfony-users+unsubscr...@googlegroups.com
> 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 symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to