Thông tin sản phẩm
Symfony Versions is also embed a set of a number of other models, that is beneficial to revise associated entities in one function. In this article, you’ll be able to create a form so you can modify a role classification and you may, proper when you look at the same means, you’ll be able to change, would and take away of several Tag stuff pertaining to one to Activity.
Tips Embed a set of Forms
2nd, let us manage a type for the job organization, having fun with an excellent CollectionType field of TagType versions. This may help us tailor all of the Level elements of a role correct inside the activity setting in itself:
If the associate submits the design, the fresh new registered study to your tags field can be used to build an enthusiastic ArrayCollection off Mark objects. Brand new range is then intent on brand new tag field of the brand new Activity and certainly will become accessed thru $task->getTags() .
At this point, that it works great, but just to modify present tags. It generally does not are suffering from but really to add the new labels or remove present of these.
You could potentially implant nested choices as much membership off because you instance. Although not, if you are using Xdebug, you can also discovered an optimum function nesting level of ‘100’ achieved, aborting! mistake. To resolve which, enhance the xdebug.max_nesting_peak PHP function, otherwise bring for each means field by hand using means_row() in lieu of leaving the complete setting simultaneously (elizabeth.g function_widget(form) ).
Allowing “new” Labels into “Prototype”
In past times you added two tags to the task on control. Now allow the profiles add as numerous tag models while they you would like directly in the fresh internet browser. This calls for some JavaScript password.
But basic, you need to allow the means collection be aware that as opposed to just a couple of, it can discover a telephone number of tags. If you don’t, you’ll see a “This form must not incorporate a lot more industries” mistake. This is accomplished towards ensure it is_create 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 proper execution.labels.vars.model are a questionnaire element that looks and seems identical to the individual means_widget(tag.*) elements in your having loop. Consequently you can call means_widget() , form_row() or bilgisayara the inner circle indir function_label() inside. You could potentially even want to give just one of the sphere (elizabeth.grams. the name community):
For people who render the complete “tags” sub-form simultaneously (age.g. function_row(form.tags) ), the information and knowledge-model characteristic is automatically set in the fresh that has div , and you should to change the second 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