Symfony use setter for Arraycollection in CreateController

271 views Asked by At

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

0

There are 0 answers