I want to do something with Symfony but it seems to be complicate : I want to include the same form twice in other one. I explain: I have two entities named Evenement
and TypeEvenement
and on my form I want that the user select a TypeEvenement
when he creates an Evenement
or he can add a TypeEvenement
.
Technically, it give this :
-> add ('typeEvenenement', 'entity', array(
'class' => 'FFESponsorBundle:TypeEvenement',
'property' => 'nom',
'multiple' => true,
))
->add ('typeEvenement', 'collection', array(
'type' => new TypeEvenementType(),
'allow_add' => true,
'allow_delete' => true,
))
But there is a conflict. Indeed, the collection take the priority on the entity. I tried to modify my form like this :
-> add ('typeEven', 'entity', array(
'class' => 'FFESponsorBundle:TypeEvenement',
'property' => 'nom',
'multiple' => true,
))
By define on my entity getters and setters for don't have error with the same values than getTypeEvenement()
, etc ... But I have a gain a conflict. So I have tried to found on other solution : I have found the readonly property. By playing a bit with JQuery, I can put this property and in this case, I can create TypeEvenement
object with the collection field. But when I want to do the opposite, the TypeEvenement
selected is not joined to the Evenement
created on the database.
I am a bit lost and I begin to think that's my problem is impossible.
Anyone has an idea about my 3 proposition or an other one to give to myself ?
Thanks guys
Aucun commentaire:
Enregistrer un commentaire