@@ -104,12 +104,10 @@ Then, create a form class so that a ``Tag`` object can be modified by the user::
104104 }
105105 }
106106
107- With this, you have enough to render a tag form by itself. But since the end
108- goal is to allow the tags of a ``Task `` to be modified right inside the task
109- form itself, create a form for the ``Task `` class.
110-
111- Notice that you embed a collection of ``TagType `` forms using the
112- :doc: `CollectionType </reference/forms/types/collection >` field::
107+ Next, let's create a form for the ``Task `` entity, using a
108+ :doc: `CollectionType </reference/forms/types/collection >` field of ``TagType ``
109+ forms. This will allow us to modify all the ``Tag `` elements of a ``Task `` right
110+ inside the task form itself::
113111
114112 // src/Form/TaskType.php
115113 namespace App\Form;
@@ -203,32 +201,20 @@ to render them:
203201
204202 {# ... #}
205203
206- When the user submits the form, the submitted data for the ``tags `` field are
207- used to construct an ``ArrayCollection `` of ``Tag `` objects, which is then set
208- on the ``tag `` field of the ``Task `` instance.
209-
210- The ``tags `` collection is accessible naturally via ``$task->getTags() ``
211- and can be persisted to the database or used however you need.
204+ When the user submits the form, the submitted data for the ``tags `` field is
205+ used to construct an ``ArrayCollection `` of ``Tag `` objects. The collection is
206+ then set on the ``tag `` field of the ``Task `` and can be accessed via ``$task->getTags() ``.
212207
213- So far, this works great, but this doesn't allow you to dynamically add new
214- tags or delete existing tags. So, while editing existing tags will work
215- great, your user can't actually add any new tags yet.
208+ So far, this works great, but only to edit *existing * tags. It doesn't allow us
209+ yet to add new tags or delete existing ones.
216210
217211.. caution ::
218212
219- In this article, you embed only one collection, but you are not limited
220- to this. You can also embed nested collection as many levels down as you
221- like. But if you use Xdebug in your development setup, you may receive
222- a ``Maximum function nesting level of '100' reached, aborting! `` error.
223- This is due to the ``xdebug.max_nesting_level `` PHP setting, which defaults
224- to ``100 ``.
225-
226- This directive limits recursion to 100 calls which may not be enough for
227- rendering the form in the template if you render the whole form at
228- once (e.g ``form_widget(form) ``). To fix this you can set this directive
229- to a higher value (either via a ``php.ini `` file or via :phpfunction: `ini_set `,
230- for example in ``public/index.php ``) or render each form field by hand
231- using ``form_row() ``.
213+ You can embed nested collections as many levels down as you like. However,
214+ if you use Xdebug, you may receive a ``Maximum function nesting level of '100'
215+ reached, aborting! `` error. To fix this, increase the ``xdebug.max_nesting_level ``
216+ PHP setting, or render each form field by hand using ``form_row() `` instead of
217+ rendering the whole form at once (e.g ``form_widget(form) ``).
232218
233219.. _form-collections-new-prototype :
234220
0 commit comments