How to Implant a couple of Variations

How to Implant a couple of Variations

Symfony Models is also implant some many other variations, that is advantageous to revise associated organizations in a single setting. On this page, you’ll be able to do a form in order to change a job group and you can, right within the exact same setting, you can easily revise, manage and take away of several Tag things connected with one Task.

How exactly to Implant some Models

Second, let’s would an application for the job organization, playing with an effective CollectionType realm of TagType models. This may help us personalize every Tag elements of a role proper into the activity form alone:

In the event the associate submits the form, new registered studies towards the labels occupation can be used to build an enthusiastic ArrayCollection of Tag objects. The latest range is then seriously interested in brand new tag arena of brand new Activity and will become accessed via $task->getTags() .

Up to now, this is effective, however, simply to change established labels. It doesn’t allow us yet , to include the labels or remove existing of those.

You could potentially embed nested choices as much membership down since you instance. not, when you use Xdebug, you could found a max mode nesting number of ‘100’ attained, aborting! mistake. To resolve which, boost the xdebug.max_nesting_peak PHP means, otherwise provide for every setting profession yourself playing with means_row() rather than helping to make the complete setting at once (e.grams mode_widget(form) ).

Enabling “new” Tags into the “Prototype”

In past times your added two tags on task on operator. Today let the profiles create as much level variations while they you need in direct this new browser. This involves a bit of JavaScript password.

However, first, you should let the form collection know that rather than precisely a few, it can discover a telephone number away from tags. Otherwise https://datingranking.net/tr/mature-quality-singles-inceleme/, you will notice a good “This form must not incorporate even more areas” error. This is done toward succeed_incorporate 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.tags.vars.prototype try a type ability that appears and you may seems same as the individual mode_widget(level.*) facets inside your to own circle. This is why you could potentially phone call setting_widget() , form_row() or mode_label() inside it. You could even always provide only one of the industries (elizabeth.grams. the name profession):

    If you provide the “tags” sub-setting immediately (e.g. form_row(means.tags) ), the details-model feature was immediately put in the that contains div , and you should to switch another JavaScript consequently.

    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