How to Implant some Variations

How to Implant some Variations

Symfony Variations is also embed a set of a great many other models, that’s beneficial to edit related entities in one single function. On this page, you’ll perform a form in order to change a task class and you may, correct into the same function, possible modify, manage and remove many Mark stuff linked to that Activity.

How exactly to Implant a couple of Models

Second, let’s perform a type to do the job entity, having fun with an effective CollectionType realm of TagType forms. This may help us customize all of the Mark elements of a task proper into the task means alone:

When the user submits the shape, the new registered studies into tags field is utilized to build an ArrayCollection out-of Mark items. The fresh new collection will be set on the newest level field of the latest Activity and will getting reached via $task->getTags() .

To date, that it is effective, but merely to modify current tags. It doesn’t allow us but really to incorporate the new labels otherwise delete existing of them.

You can implant nested choices as many profile off since you instance. not, when you use Xdebug, it is possible to located a maximum mode nesting amount of ‘100’ achieved, aborting! mistake. To resolve so it, enhance the xdebug.max_nesting_height PHP setting, or promote each form profession by hand playing with means_row() in the place of leaving the whole means immediately (elizabeth.grams function_widget(form) ).

Allowing “new” Labels on the “Prototype”

In the past your extra several labels towards activity from the operator. Now let the pages put as many level forms because they you would like directly in the brand new web browser. This involves a touch of JavaScript code.

However, earliest, you should allow form range remember that as opposed to just a couple, it can located a telephone number out of tags. If not, you’ll see a beneficial “This type must not have even more areas” mistake. This is done towards the enable it to be_add 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 are a form ability that appears and you will feels just like the person setting_widget(mark.*) facets inside your to have cycle. As a result you can telephone call form_widget() , form_row() or setting_label() on it. You could even choose to give one of their industries (e.grams. the name occupation):

    For those who render the entire “tags” sub-function immediately (elizabeth.grams. setting_row(function.tags) ), the info-prototype feature was immediately placed into the latest that contains div , and you need to to alter the next JavaScript accordingly.

    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