How exactly to Implant some Variations

How exactly to Implant some Variations

Symfony Forms can also be implant a couple of many other forms, that is beneficial to change relevant entities in one form. In this article, you’ll perform an application in order to modify a task group and you will, right inside the exact same mode, you’ll change, carry out and take off of numerous Mark items related to one to Activity.

Just how to Embed a set of Versions

2nd, let us would a type to do the job entity, playing with a beneficial CollectionType world of TagType versions. This can allow us to personalize all Tag parts of a job correct when you look at the task means alone:

When the affiliate submits the proper execution, the newest recorded studies for the tags occupation is utilized to construct a keen ArrayCollection away from Tag items. The new range will be set on the tag arena of the new Activity and can feel utilized through $task->getTags() .

So far, so it works great, but just to revise existing tags. It doesn’t have developed but really to incorporate new labels otherwise erase present of these.

You can embed nested series as many profile off since you such. But not, by using Xdebug, you may found a max mode nesting quantity of ‘100’ hit, aborting! error. To fix it, improve the xdebug.max_nesting_level PHP setting, or render for every single setting community by hand playing with form_row() in place of leaving the complete function at a time (age.grams means_widget(form) ).

Making it possible for “new” Labels with the “Prototype”

In earlier times your added one or two tags with the activity on controller. Today allow profiles include as much level forms because they you desire in direct the brand new internet browser. This requires some JavaScript password.

However, first, you will want to allow the function range remember that as opposed to precisely a few, it can discovered a phone number of tags. If you don’t, you will see a “This type must not consist of additional areas” mistake. This is accomplished to the enable it to be_create solution:

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

    in your template:

    The shape.labels.vars.model is actually a type element that appears and you can seems same as the person function_widget(level.*) facets within your to possess loop. Consequently you might call mode_widget() , form_row() or function_label() in it. You can actually choose bring only 1 of the sphere (elizabeth.g. the name profession):

    For many who give the entire “tags” sub-setting simultaneously (elizabeth.grams. function_row(mode.tags) ), the content-model characteristic try instantly added to the latest with which has div , and you ought to to alter next JavaScript appropriately.

    Now add some JavaScript to read this attribute and dynamically add new tag forms when the user clicks the “Add a tag” link. Add a