[Form] Création d'un formulaire multi entité
Bonjour à tous,
Je suis actuellement confronté à un problème:
J'ai besoin de créer une unique formulaire qui va regrouper la modification d'un certain nombre d'entité.
Un code explique mieux qu'un long discours, voilà le mien:
CourrierController:
Code:
1 2 3 4
| <?
$courriers = array('courriers' => $this->getDoctrine()->getRepository('WebscmServiceBundle:Courrier')->findAll());
$form = $this->createForm(new TotalCourrierCommandeType, $courriers);
$form->createView(); |
TotalCourrierCommandeType:
Code:
1 2 3 4 5 6 7
| <?
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('courriers', 'collection', array ('type' => new CourrierCommandeType))
;
} |
CourrierCommandeType
Code:
1 2 3 4 5 6 7 8 9
| <?
public function buildForm(FormBuilder $builder, array $options)
{
$builder
->add('commande')
->add('courrierCommande')
->add('CommentaireCourrierCommande', 'textarea', array('max_length' => 255))
;
} |
Je me retrouve avec une erreur qui me dit : "Expected argument of type "Webscm\ServiceBundle\Entity\Courrier", "array" given"
Quelqu'un saurait comment corriger ce qui en va pas ?
Merci d'avance =)