symfony/symfony — Issue #3075: [Form] The prototype is an empty string for a collection which is not one-to-many
Author: chetzof
Created: 2012-01-09 23:09:33+00:00
State: open

The prototype is an empty string for a collection which is not backed by one-to-many relationship

```php
{% debug form_widget(form.extraAttributes.get('prototype')) %}
```
returns `string(0) ""`

buildForm method
```php
$builder
->add('images', 'collection', array('type' => new ProductimageType(), 'allow_add' => true, 'allow_delete' => true, 'label'=> 'Imagini', 'prototype' => true ))
->add('extraAttributes', 'collection', array('type' => 'hidden', 'allow_add' => true, 'allow_delete' => true, 'label'=> 'Attribute', 'prototype' => true))
;
```
`images` ,which is one-to-many relationship in Doctrine2, displays the prototype properly, whereas `extraAttributes` prototype is empty

Field definitions:

```php
/**
* @ORM\OneToMany(targetEntity="Productimage", mappedBy="product", orphanRemoval=true, cascade={"persist"})
*/
private $images;

/**
* @var array
* @ORM\Column(name="Other", type="array", nullable=true)
*/
private $extraAttributes;
```

I add

manually via javascript, and the engine properly adds fields as intended, so basically everything works except the prototype generation.