BeelabTagBundle
BeelabTagBundle copied to clipboard
Updating Without TagsText?
Am I right in thinking that if I have an entity that I've previously tagged, if I simply load the entity, change something unrelated to tags on it, and then persist it, that it will lose all the tags? (Because the TagSubscriber
setTags
method relies on you having called getTagsText
/setTagsText
, and if you haven't, it will think you mean to remove all the tags?)
Or am I possibly doing something dumb? :)
Each time you update an entity, you should pass back every value, even if unchanged.
I see -- do you have any hints on the best way of doing this when you're updating an entity without using a form? I have things like commands and message handlers and whenever they touch my entity it loses its tags. At the moment I'm working around this by just calling this->getTagsText()
in a postLoad Doctrine callback to populate the tag text with the existing Tags, but it seems a bit of a hack. And I'm thinking that if I add Tag relations rather than using setTagsText those relations won't be saved, yes? Just want to make sure I'm understanding what's going on.
Forms are unrelated. Once you get an entity, no matter how, and you need to re-save it (again, no matter how), each property of the entity needs to be non-empty (unless, of course, making a property empty is intentional).
In a command/handler scenario, I would populate $tagsText
in the command constructor, as soon as I get the entity.
Thank you for clarifying!