Now I' trying to do this 
http://symfony.com/doc/current/book/forms.html#embedding-a-collection-of-forms
with:

class PaymentFormType extends AbstractType {
    public function buildForm(FormBuilder $builder, array $options) {
        $builder->add('paymentType');
        $builder->add('payment', 'collection', array(
            'type' => new CreditCardFormType()
        ));
    }

    public function getDefaultOptions(array $options) {
        return array(
            'data_class' => 'My\UserEntity',
        );
    }
}

, but

I have try to render it with

{{ form_widget(form) }} - collection not rendered

and

{{ form_row(form.paymentType) }}
{{ form_widget(form.payment) }} - no render

and

{{ form_row(form.paymentType) }}
{{ collection_widget(form) }} - no render

throws The function "collection_widget" does not exist.

In 
https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/TwigBundle/Resources/views/Form/div_layout.html.twig
collection_widget is never used in form_widget. Strange.

Anyone knows how to render collections?

Also, I want to add CreditCardFormType as well, but don't know how.

On 10 мај, 11:44, umpirsky <umpir...@gmail.com> wrote:
> I see children can be added to form. But nothing in the doc.
>
> On 10 мај, 11:40, umpirsky <umpir...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I have one form that have several subforms. Depending on radio button
> > clicked, javascript expands one subform.
>
> > In order to achieve this using form component, I have created many
> > separated form objects, which are rendered under main form.
>
> > Depedngin on radio
>
> > switch ($request->get('radio'))
>
> > I validate one of many forms.
>
> > In order to disable HTML5 required attirbute I marked forms as not
> > required unless radio submitted for that form
>
> > $form1 = $factory->create(new CreditCardFormType(), null,
> > array('required' => $form1Required));
>
> > But this have some impact on select elements on the form. When form is
> > marked as not required, select elements don't have empty option
> > selected by default, if marked required, they don't have empty option.
>
> > Anyone knows wy, and how to unify this behaviour?
>
> > Also, if there is some better way to handle subforms, please suggest.
>
> > Regards,
> > Sasa Stamnekvic.

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