|
1 | 1 | .. index::
|
2 | 2 | single: Form; Embed collection of forms
|
3 | 3 |
|
4 |
| -Edit Related Entities in a Single Form |
5 |
| -====================================== |
| 4 | +How to Embed a Collection of Forms |
| 5 | +================================== |
6 | 6 |
|
7 |
| -To edit associated entities in the same form, Symfony has the concept of |
8 |
| -Form "Collections". Think of it as a series of sub-forms, embedded into |
9 |
| -the main form. |
| 7 | +Symfony Forms can embed a collection of many other forms, which is useful to |
| 8 | +edit related entities in a single form. In this article, you'll create a form to |
| 9 | +edit a ``Task`` class and, right inside the same form, you'll be able to edit, |
| 10 | +create and remove many ``Tag`` objects related to that Task. |
10 | 11 |
|
11 |
| -The example used in this article is a ``Task`` entity that relates to |
12 |
| -a ``Tag`` entitiy. The goal is to create a single form for tasks, that |
13 |
| -also allows to edit/create/remove many tags associated with that task. |
14 |
| - |
15 |
| -Here's the ``Task`` and the ``Tag`` entity:: |
| 12 | +Let's start by creating a ``Task`` entity:: |
16 | 13 |
|
17 | 14 | // src/Entity/Task.php
|
18 | 15 | namespace App\Entity;
|
@@ -48,8 +45,11 @@ Here's the ``Task`` and the ``Tag`` entity::
|
48 | 45 |
|
49 | 46 | .. note::
|
50 | 47 |
|
51 |
| - The `ArrayCollection`_ is specific to Doctrine and is basically the |
52 |
| - same as using an ``array``. |
| 48 | + The `ArrayCollection`_ is specific to Doctrine and is similar to a PHP array |
| 49 | + but provides many utility methods. |
| 50 | + |
| 51 | +Now, create a ``Tag`` class. As you saw above, a ``Task`` can have many ``Tag`` |
| 52 | +objects:: |
53 | 53 |
|
54 | 54 | .. code-block:: php
|
55 | 55 |
|
|
0 commit comments