Andresch Serj
Andresch Serj

Reputation: 37358

custom formtype wraps ArrayCollection in ArrayCollection

I have a ManyToMany Relation (AdditionalCostTemplate>Accommodation) and i have a custom formtype extending EntityType to fill the Accommodations in my AdditionalCostTemplate.

If i use the default symfony2 EntityType Formtype, it all works well. If i use my custom EntityType it wraps my Accommodation Entities in an additional ArrayCollection. Now i stripped my custom entity to just having a different name, nothing else. The error still appears.

My Annotations:

/**
 * AdditionalCostTemplate
 *
 * @ORM\Table()
 * @ORM\Entity()
 */
class AdditionalCostTemplate
{
    /**
     * @var PersistentCollection
     *
     * @ORM\ManyToMany(targetEntity="Acme\AccommodationBundle\Entity\Accommodation", cascade={"persist", "remove"}, orphanRemoval=true)
     */
    private $accommodations;
    [...]

My Entity FormType:

class CallbackEntityType extends EntityType
{
    public function getParent()
    {
        return 'entity';
    }

    public function getName()
    {
        return 'acme_callback_entity_type';
    }
}

Anyone any ideas?

Upvotes: 0

Views: 105

Answers (1)

Jovan Perovic
Jovan Perovic

Reputation: 20191

Not sure but could it be because you're both extending the entity type and defining it as parent?

Try replacing the extends EntityType with extends AbstractType...

Upvotes: 1

Related Questions