Symfony are only able to make the plural-to-just one conversion (elizabeth.grams. regarding labels property for the addTag() method) to own English terms. Code written in any other language won’t behave as asked.
To store the latest tags with Philosophy, you really need to believe a few a lot more some thing. Very first, if jaumo masaüstü you don’t iterate overall of your the latest Mark items and you can telephone call $entityManager->persist($tag) for each, you are getting a mistake from Philosophy:
To fix that it, you may choose to «cascade» new persevere process immediately in the Task target to any related tags. To take action, are the cascade option to your ManyToMany metadata:
- Annotations
- YAML
- XML
A second potential question works together with the new Running Front and Inverse Edge of Dple, in case the «owning» section of the matchmaking is «Task», then dedication will continue to work as labels was properly additional to the Task. Yet not, in case your getting front side is found on «Tag», then you’ll must do more try to ensure that the correct section of the dating are changed.
The trick is to make sure that new single «Task» is determined on every «Tag». One way to accomplish that should be to then add more reasoning so you’re able to addTag() , to create of the form kind of given that of the_source is set so you’re able to not true :
Allowing Tags to be Removed
The next step is so that the latest removal of a certain items regarding range. The clear answer is similar to allowing labels to be additional.
Template Adjustment
The newest allow_remove option means if an item of a portfolio actually sent for the entry, the fresh related information is taken out of the range for the servers. Making sure that so it to operate in the an HTML means, you must take away the DOM function on the range product to help you go off, before entry the form.
Whenever a tag means is completely removed regarding DOM and you may recorded, this new removed Tag target won’t be included in the range enacted to setTags() . Based on your time and effort level, this may or may not be adequate to actually get rid of the relationships involving the got rid of Level and Task target.
Whenever deleting things such as this, you may have to do a bit of a bit more strive to make sure the matchmaking between your Activity additionally the got rid of Tag was securely removed.
Usually in such a case you should have a many-to-one to relationship as well as the erased labels will disappear and you will persist accurately (including brand new labels and additionally performs effortlessly).
But when you provides a one-to-many dating or a lot of-to-of a lot reference to good mappedBy for the Activity entity (meaning Task is the «inverse» side), you’ll need to carry out a lot more work with the newest removed labels to persist truthfully.
In such a case, you could potentially customize the controller to eliminate the relationship into eliminated level. This takes on you have some revise() step that is dealing with «update» of your own Activity:
As you can see, incorporating and you may removing the current weather truthfully will be challenging. If you don’t features a lots of-to-of several matchmaking where Activity is the «owning» front side, you’ll need to do extra work to make sure that the new dating are properly up-to-date (whether you’re adding the fresh new labels or removing established labels) on each Level object itself.
The fresh new Symfony community has established particular JavaScript bundles giving the fresh new capability wanted to put, edit and you can erase elements of the brand new collection. Have a look at /symfony-range bundle having progressive browsers and also the symfony-collection plan centered on jQuery for the remainder of internet browsers.
You must carry out each other addTag() and removeTag() measures, or even the proper execution have a tendency to nonetheless play with setTag() regardless of if from the_reference try not the case . Become familiar with much more about the newest removeTag() approach afterwards in this article.
