Nischal Bachu
Nischal Bachu

Reputation: 127

Symfony OneToMany Persistence using entity/collection field type

My Problem: I cannot get an associated Entity to save using the entity field type or collection field type.

My Database Relations My Database Relations

Database Structure Description:




What I want to Achieve

enter image description here

How I want to display my Usage Form


What I want to display

My Controller

My Entities

Form Type

Twig Template

ViewTransformer

ObjectToArrayTransformer

My Problem: When I submit the form, nothing happens, the new telephone number I selected is not persisted.

Upvotes: 2

Views: 459

Answers (1)

Guillaume Fache
Guillaume Fache

Reputation: 813

I think your problem is that in your Usage Entity, you don't cascade the persist operation. You should try this :

@ORM\OneToMany(targetEntity="Telephone", mappedBy="usage", cascade={"persist"})

Hope this helps

Upvotes: 2

Related Questions