Hi guys, How to generate following html table structure in twig?
{% for source in form.sources %}
  <tr>
   <td><input type="checkbox" id="check1" /><label
for="check1">Yes</label></td>
   <td>Foo</td>
   <td><input type="checkbox" id="check2" /><label
for="check2">Yes</label></td>
   <td>Bar</td>
</tr>
{% endfor %}

On Tue, May 10, 2011 at 10:45 AM, barbacan <julien.ga...@gmail.com> wrote:

> Thanks for this example! But this doesn't work with me. With this
> call:
>
> {% for address in form.addresses %}
>  <tr>
>    <td>
>      {{ form_widget(address.zipcode) }}
>      {{ form_errors(address.zipcode) }}
>    </td>
>  </tr>
> {% endfor %}
>
> I have this error:
>
> Method "zipcode" for object "Symfony\Component\Form\FormView" does not
> exist in TestBundle:User:form.html.twig at line 8
>
>
> On 7 mai, 14:33, ryan weaver <weaverr...@gmail.com> wrote:
> > Hi there!
> >
> > Take a look at this example:
> https://github.com/beberlei/AcmePizzaBundle/blob/master/Resources/vie...
> >
> > 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, TNhttp://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-coll.
> ..
> > > ?)
> >
> > > 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
>

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