How-to Embed a collection of Forms

Symfony Models is embed a couple of a great many other versions, which is useful to revise relevant organizations in one mode. In this article, it is possible to carry out a form so you’re able to change a role group and, best in the exact same function, you are able to revise, carry out and take away many Mark stuff pertaining to one Task.

How to Embed a collection of Models

Next, why don’t we carry out a form for the job organization, playing with a beneficial CollectionType realm of TagType forms. This will help us tailor most of the Tag components of a job correct in the activity mode itself:

If representative submits the form, the latest registered investigation for the labels industry is employed to create an ArrayCollection away from Mark objects. This new range will then be seriously interested in the newest tag world of the brand new Task and will be accessed thru $task->getTags() .

To date, which works great, but merely to revise existing tags. It does not allow us but really to provide the labels or flirt4free kvízy erase existing of them.

You can embed nested series as numerous membership off because you such as for example. Yet not, when you use Xdebug, you can even found a maximum setting nesting amount of ‘100’ reached, aborting! error. To solve so it, increase the xdebug.max_nesting_level PHP setting, or bring per mode job manually having fun with form_row() in the place of leaving the complete function at a time (age.g form_widget(form) ).

Making it possible for “new” Tags to your “Prototype”

In earlier times you added a couple tags to your task on control. Today let the profiles put as many level versions while they you want in direct the brand new internet browser. This involves a touch of JavaScript code.

But first, you should allow function collection remember that as opposed to exactly a couple, it can discover an unknown number off labels. If you don’t, you will notice good “This type should not consist of a lot more fields” error. This is accomplished towards allow it to be_put choice:

The allow_add option also makes a prototype variable available to you. This “prototype” is a little “template” that contains all the HTML needed to dynamically create any new “tag” forms with JavaScript. To render the prototype, add the following data-prototype attribute to the existing

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *