1
votes

I am passing a load of data to my view which looks like this

object(stdClass)#328 (11) { 
    ["__CLASS__"]=> string(30) "Nick\AlertBundle\Entity\Alert" 
    ["id"]=> int(11) 
    ["searchCommand"]=> string(12) "A20APRLONLAX" 
    ["isConnecting"]=> string(2) "no" 
    ["lastUpdated"]=> object(stdClass)#422 (3) { ["__CLASS__"]=> string(8) "DateTime" ["date"]=> string(25) "2015-02-26T12:16:02+00:00" ["timezone"]=> string(13) "Europe/London" } 
    ["isDeleted"]=> bool(false) 
    ["alertStatus"]=> string(6) "Active" 
    ["bookingClass"]=> array(2) { 
        [0]=> string(37) "Nick\AlertBundle\Entity\BookingClass" 
        [1]=> string(37) "Nick\AlertBundle\Entity\BookingClass" 
    } 
    ["pseudo"]=> array(1) { 
        [0]=> string(32) "Nick\AlertBundle\Entity\Pseudos" 
    } 
    ["flightNumbers"]=> array(1) { 
        [0]=> string(38) "Nick\AlertBundle\Entity\FlightNumbers" 
    } 
    ["availability"]=> array(4) { 
        [0]=> string(37) "Nick\AlertBundle\Entity\Availability" 
        [1]=> string(37) "Nick\AlertBundle\Entity\Availability" 
        [2]=> string(37) "Nick\AlertBundle\Entity\Availability" 
        [3]=> string(37) "Nick\AlertBundle\Entity\Availability" 
    } 
} 

So the above represents one Alert, and an Alert can have one or more bookingClass, pseudo, flightNumbers and availability.

I am trying to make a layout which looks like this image layout

At the moment, this is what I am attempting

{% for alert in alerts %}
    Alert #{{ alert.id }}
    <br>

    {% for p in alertPseudo %}
        {{ p.alertPseudo }}
    {% endfor %}
{% endfor %}

So that gets the Alert number for me fine, but my first problem is trying to access something from the pseudo element in the data (which is a linked Entity). Whatever I try, I get Variable "alertPseudo" does not exist in ...

Its easy to get access to it in my controller, I can just use the methods in its class, can I do this in Twig?

Thanks

1

1 Answers

1
votes

I don't know exactly what you mean by alertPseudo. May be what you try to do is

{% for p in alert.pseudo %}