Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony 2 Form, field collection doesn't display
    primarykey
    data
    text
    <p>I would like to create a form which can add multiple etape. I create the form like this:</p> <p>//FORM</p> <pre><code> namespace RBO\TryBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; use RBO\TryBundle\Entity\Try; class TryType extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $builder-&gt;add('etapes', 'collection', array( 'type' =&gt; new EtapeType(), 'allow_add' =&gt; true, 'allow_delete' =&gt; true, 'prototype' =&gt; true, 'label' =&gt; 'Etapes' )); } public function getName() { return 'try'; } public function getDefaultOptions(array $options) { return array( 'data_class' =&gt; 'RBO\TryBundle\Entity\Try', 'csrf_protection' =&gt; true, 'csrf_field_name' =&gt; '_token', // a unique key to help generate the secret token 'intention' =&gt; 'try_item', ); } } </code></pre> <p>// EtapeType</p> <pre><code>&lt;?php namespace RBO\TryBundle\Form\Type; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; use RBO\TryBundle\Entity\Etape; class EtapeType extends AbstractType { public function buildForm(FormBuilder $builder, array $options) { $builder-&gt;add('name', 'text'); } public function getDefaultOptions(array $options) { return array( 'data_class' =&gt; 'RBO\TryBundle\Entity\Etape', ); } public function getName() { return 'etape'; } </code></pre> <p>}</p> <p>// Display in twig template</p> <pre><code>{{ form_row(form.etapes) }} </code></pre> <p>The Entity Try have a property etapes which is an ArrayCollection (defined in the constructor)</p> <p>This code render nothing expect the label. Did I miss something?</p> <p>Thank you by advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload