I have a twig template in my Symfony2 project. In the twig template, I have an entity object. This entity object is linked to another entity with oneToMany relation.
Example:
{{ submission }} -> Submission entity
{{ submission.histories }} -> Histories entity -> I have here an array collection of histories
The entity histories has a field "state_to"
My goal is to get only the histories object where the state_to is 4
I tryed like that:
{{ submission.histories('status_to', 4)[0] }}
But this is not working.
I know that I can use:
{% for history in submission.histories %}
{% if history.statusTo == 4 %}
{{ history.statusDate|date("d F Y") }}
{% endif %}
{% endfor %}
But I am allmost sure that there is a nicer way.
history.statusTo = 4and pass these to the template. Logic like this should not be included in a template.