custom formtype wraps ArrayCollection in ArrayCollection

115 views Asked by At

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?

1

There are 1 answers

1
Jovan Perovic On BEST ANSWER

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