jeudi 9 avril 2015

Symfony2 How to create one form for many the same entities?

I have the following entity:



// ZaquPL/MyBundle/Entity/Task.php
protected $name;
protected $order;

public function getName() {...}
public function setName($name) {...}
public function getOrder() {...}
public function setOrder($order) {...}


I would like one form with many entities. It's becouse I want to sort tasks "drag and drop) and change their names in one form, with one submit button and without AJAX.


It should looks like in that schema:



[GRAB AND MOVE <INPUT name="order[1]">] <INPUT name="name[1]">
[GRAB AND MOVE <INPUT name="order[2]">] <INPUT name="name[2]">
[GRAB AND MOVE <INPUT name="order[3]">] <INPUT name="name[3]">
[GRAB AND MOVE <INPUT name="order[4]">] <INPUT name="name[4]">
[GRAB AND MOVE <INPUT name="order[5]">] <INPUT name="name[5]">
[GRAB AND MOVE <INPUT name="order[6]">] <INPUT name="name[6]">


I know how to create view, how to use jquery UI drag and drop components etc, so don't worry about that. I only ask how to create this form using Symfony FormBuilder. Have you any idea?


Aucun commentaire:

Enregistrer un commentaire