Symfony is only able to result in the plural-to-only one transformation (e.g. regarding the tags assets on addTag() method) for English conditions. Code written in any language wouldn’t behave as expected.
To save the labels which have Philosophy, you should envision a few a great deal more some thing. First, unless you iterate overall of the the Tag things and you can phone call $entityManager->persist($tag) for each, you get an error from Philosophy:
To solve this, you could potentially “cascade” the newest persist process automatically from the Task target to any related labels. To do so, range from the cascade choice to your own ManyToMany metadata:
- farmersonly
- Annotations
- YAML
- XML
The next prospective point works with the Possessing Front side and you may Inverse Side of Dple, in case the “owning” side of the matchmaking is actually “Task”, next hard work is guaranteed to work as labels is securely additional into the Task. Although not, if for example the having front side is found on “Tag”, then you’ll definitely want to do a bit more try to ensure that the right side of the relationships is actually modified.
The key is to make sure the latest single “Task” is determined on every “Tag”. One method to do this is to try to add some a lot more logic so you can addTag() , called from the form form of since the from the_resource is set in order to not the case :
Enabling Tags getting Removed
The next phase is to let the new deletion away from a specific goods throughout the range. The clear answer is like enabling tags getting additional.
Layout Variations
The brand new enable it to be_delete option ensures that in the event the an item of a profile actually delivered into submitting, the associated data is taken out of this new range towards servers. With the intention that that it to be effective for the a keen HTML mode, you must remove the DOM feature for the range product in order to come-off, in advance of distribution the form.
When a label form is removed about DOM and you will submitted, brand new removed Tag object are not included in the range passed so you can setTags() . Depending on their persistence layer, this could or might not be sufficient to indeed take away the relationships amongst the eliminated Mark and you can Task object.
Whenever removing stuff in this way, you may need to do a bit of a bit more try to ensure that the matchmaking between your Activity in addition to eliminated Tag is securely eliminated.
Generally in this situation you’ll have a quite a few-to-you to dating as well as the erased labels will recede and you may persevere accurately (including brand new tags and additionally works without difficulty).
But when you have a one-to-of numerous relationship otherwise a plenty of-to-of many connection with a beneficial mappedBy toward Activity organization (definition Activity is the “inverse” side), you will have to create so much more work with new eliminated tags to persist precisely.
In this instance, you might customize the control to eradicate the partnership to your removed tag. That it takes on you have particular change() action that’s handling the “update” of your own Task:
Clearly, incorporating and you will removing the weather accurately can be tricky. If you do not provides a lots of-to-of numerous matchmaking where Activity is the “owning” side, you will need to carry out more work to make certain the latest relationship is actually securely updated (whether you are adding the latest labels or deleting present tags) on each Level object in itself.
The brand new Symfony community has generated specific JavaScript bundles that provide new capability necessary to create, edit and you may remove areas of the latest range. Have a look at /symfony-collection plan for modern web browsers while the symfony-range package considering jQuery throughout internet explorer.
You have got to carry out both addTag() and you may removeTag() actions, or even the proper execution will still have fun with setTag() regardless if by the_site are untrue . You will then see more about the new removeTag() strategy later in this article.
Leave A Comment