0

I have a form to upload documents and each document can be assigned to one or several agencies. every Agency belongs to one specific market and one market can have several agencies. In my form, only the agencies can be selected but when listing my created document, I want the markets of the agencies to be listed, as well. So now to my question: I'm looking for a way to access every single object of the arraycollection "agency" and then use my getter for the markets on each of these objectc to get and then set the markets for the document that has been created. It's hard to describe it all properly, so feel free to ask whatever is unclear! I'd be happy about any help!

1 Answer 1

2

ArrayCollection is iterable. So you can simply do something like:

foreach($document->getAgencies() as $agency) {
    $agency->getMarket();
}
Sign up to request clarification or add additional context in comments.

4 Comments

thanks! that's exactly what I've been looking for! Only now, I don't get any values back. so it seems as if it's null, even though something has been selected..
You must do this after the form has been submitted and processed and the form you are using must know how to update your entities. This would be beyond the scope of this question, but you will need to do some debugging. I can't help much without looking at the code.
I asked a new question to that topic with code right there: stackoverflow.com/questions/45983542/… :))
This should be marked as the correct answer sonja. This is exactly what would be done.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.