Symfony Forms is also implant some many other versions, that is beneficial to modify associated agencies in one single means. On this page, you’ll be able to would a questionnaire in order to modify a role classification and you may, correct in exact same setting, you’ll change, perform and take off many Level objects regarding you to definitely Activity.
Tips Embed a couple of Versions
Next, let us manage a form for the job organization, using a CollectionType field of TagType variations. This may help us personalize all Tag components of a task best for the activity form itself:
If representative submits the proper execution, the registered analysis to the labels occupation is used to create a keen ArrayCollection away from Mark objects. The newest collection is then intent on the brand new level field of the fresh new Activity and can getting utilized through $task->getTags() .
At this point, so it is effective, but in order to edit current tags. It doesn’t allow us but really to include the fresh new tags or delete current of these.
You could embed nested series as much profile off as you like. But not, by using Xdebug, it’s also possible to discover a max means nesting number of ‘100’ achieved, aborting! error. To fix so it, increase the xdebug.max_nesting_top PHP function, or give each mode job by hand using form_row() in lieu of helping to make the complete mode at a time (elizabeth.grams function_widget(form) ).
Enabling “new” Tags for the “Prototype”
In the past your extra a couple tags to the activity regarding operator. Today let the pages add as numerous level models because they you desire in direct the fresh new browser. This calls for some JavaScript password.
But earliest, you need to allow the function range know that in lieu of exactly two, it will receive an unknown number regarding labels. If not, you will observe good “This type cannot have additional areas” error. This is accomplished with the allow it to be_include 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
- in your template:
The design.labels.vars.prototype is actually a questionnaire function that appears and seems same as the individual means_widget(tag.*) issue inside your to possess circle. Thus you might label function_widget() , form_row() otherwise setting_label() on it. You might also choose promote singular of the areas (e.g. the name profession):
For individuals who give the whole “tags” sub-mode at a time (elizabeth.g. means_row(function.tags) ), the data-model characteristic is actually immediately put into the brand new containing div , and you ought to adjust the following JavaScript consequently.
Now add some JavaScript to read this attribute and dynamically add new tag forms when the user clicks the “Add a http://datingranking.net/pl/willow-recenzja tag” link. Add a