Reputation: 9011
I added a couple of fields in my Entity1
file like:
/**
* @var integer $typeid
*
* @ORM\Column(name="typeid", type="integer")
*/
private $typeid;
And added getter and setter method for it.
In my controller I am fetching data using:
$result = $entityManager->getRepository('MyBundle:Entity1')
->findby(array('year' => $year));
I send my result to the twig file in an array with name 'entities'
(say)
In my twig file I loop through all the entities in the array and display the
data.
I am getting two exceptions:
1/2
ErrorException: Notice: serialize(): "id" returned as member variable from __sleep() but does not exist in /var/www/Symfony/vendor/symfony/src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php line 29
2/2
Exception: Symfony\Bundle\FrameworkBundle\DataCollector\RequestDataCollector::serialize() must return a string or NULL
I am new to Symfony 2, and am not sure whats happening. I am guessing that the new fields that I added in the Entity file is causing some problem.
Upvotes: 2
Views: 1039
Reputation: 113
I have the same error when add to my Product entity this code:
/**
* @var Type $type
*
* @ORM\ManyToOne(targetEntity="Acme\StoreBundle\Entity\Product\Type")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id")
*/
private $type;
Here my template:
{% render "StoreBundle:Product:list" with { 'products': products } %}
But if I change template:
{% for product in products %}
<li>{{ product.name }}</li>
{% endfor %}
... or change hydration mode to array:
$products = $this->getDoctrine()
->getRepository('StoreBundle:Product')
->getQuery()
->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
... error does not occur
Upvotes: 1