Symfony Models is also implant a set of a number of other variations, that is good for revise related entities in one single mode. In this article, possible perform an application to help you change a task classification and you will, best from inside the exact same function, you’ll modify, manage and take away of many Tag things about one Task.
Just how to Embed some Versions
Next, why don’t we carry out a type for the task organization, using good CollectionType realm of TagType versions. This may allow us to customize the Mark areas of a role best in activity form in itself:
In the event that member submits the form, this new filed investigation to your tags career is employed to build an enthusiastic ArrayCollection out of Level things. Brand new collection will then be intent on the new level realm of the brand new Activity and will end up being utilized via $task->getTags() .
At this point, that it is effective, however, only to change established labels. It generally does not have developed yet to incorporate the fresh tags otherwise erase established ones.
You can embed nested choices as many membership down as you instance. Although not, if you utilize Xdebug, you can also located a maximum form nesting number of ‘100’ attained, aborting! error. To resolve that it, boost the xdebug.max_nesting_level PHP function, otherwise render for each mode career yourself using setting_row() in place of leaving the whole setting simultaneously (elizabeth.grams form_widget(form) ).
Enabling “new” Tags with the “Prototype”
In earlier times you additional a couple of labels toward task about control. Now allow the users incorporate as numerous level variations because they need directly in the brand new internet browser. This calls for a touch of JavaScript code.
But earliest, you ought to allow mode collection remember that as opposed to just two, it can found a telephone number off tags. If not, you’ll see a beneficial “This form shouldn’t incorporate most sphere” mistake. This is accomplished on the enable it to be_incorporate choice:
The allow_add option also makes a prototype variable available to you. This “prototype” is a little “template” loveandseek hile 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 form.labels.vars.prototype try a questionnaire ability that looks and you can seems identical to the person form_widget(mark.*) points in your to have cycle. This means that you might label function_widget() , form_row() or form_label() involved. You can actually choose give only one of the industries (age.grams. the name field):
For individuals who bring the “tags” sub-mode at the same time (age.g. means_row(mode.tags) ), the data-model characteristic is immediately put in the brand new that features div , and you ought to to change the following JavaScript correctly.
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