How-to Embed some Variations

How-to Embed some Variations

Symfony Versions can also be embed some a great many other models, that is advantageous to change related agencies in one means. In this article, you’ll would a type so you can revise a role category and you will, correct into the exact same mode, you’ll be able to modify, would and remove many Tag objects connected with one Activity.

How exactly to Embed a couple of Versions

Second, let’s manage a form to do the job organization, using good CollectionType world of TagType versions. This may allow us to personalize all of the Mark elements of a role proper in task setting in itself:

In the event that representative submits the form, the newest submitted investigation for the labels community is employed to construct an enthusiastic ArrayCollection out of Mark things. The newest collection is then seriously interested in this new mark arena of the latest Activity and will getting reached via $task->getTags() .

Up until now, that it is effective, but only to edit existing tags. It generally does not have developed but really to incorporate the fresh new labels otherwise remove existing ones.

You could embed nested stuff as numerous profile down as you such as for example. However, if you are using Xdebug, you can also located a maximum form nesting quantity of ‘100’ reached, aborting! mistake. To solve that it, help the xdebug.max_nesting_level PHP mode, otherwise provide for each and every means job manually playing with form_row() in lieu of rendering the entire function at a time (e.g mode_widget(form) ).

Allowing “new” Tags towards “Prototype”

Prior to now you added a couple labels to the activity throughout the control. Today allow users put as numerous mark variations because they you need in direct the latest internet browser. This involves a bit of JavaScript password.

However, basic, you really need to let the setting collection remember that unlike exactly several, it does located an unknown number of labels. If you don’t, you will observe good “This type cannot consist of additional sphere” mistake. This is done towards the allow_put option:

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 proper execution.labels.vars.prototype is actually a questionnaire ability that appears and you can feels just like the person setting_widget(mark.*) issues in your having loop. Because of this you might telephone call form_widget() , form_row() or mode_label() with it. You can actually will provide one of the sphere (elizabeth.grams. the name career):

    If you promote the “tags” sub-function at the same time (age.grams. function_row(function.tags) ), the knowledge-prototype characteristic are immediately set in the brand new who has div , and you need to to evolve another 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

Recent Comments