Symfony use setter for Arraycollection in CreateController

主宰稳场 提交于 2019-12-24 18:50:22

问题


I'd like to create an upload form for documents. It's possible to select several so called 'agencies' and each of these agencies belongs to one specific market. What I want to do is, set the markets automatically. So in my controller I had something like this:

$document->setMarket($document->getAgencies()->getMarket());

But since the agencies are an ArrayCollection, I can't call a getter on them. So I was thinking about a for each loop in order to get the markets for every single agency. Would that work and if yes how would I do it best and most efficiently?

Would be happy about tips and tricks :D

来源:https://stackoverflow.com/questions/45963672/symfony-use-setter-for-arraycollection-in-createcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!