eav-manager
eav-manager copied to clipboard
Adding values to a multiple fields is not working
As said in documentation to have a collection we should add multiple
to our field. But this does not work as the collection is not mapped to the EAV value :
$publication->get('publishedPublications')->add($publishedPublication);
dump($publication->get('publishedPublications'));
Doctrine\Common\Collections\ArrayCollection {#3386
-elements: []
}
Nevermind it can be done in the old way :
$data = $publication->get('publishedPublications');
$data->add($publishedPublication);
$publication->set('publishedPublications', $data);
Note that is not intuitive that this code is not similar to the previous one...
This is not normal and should be working as expected with the 2 syntax
It should also work like this:
$publication->add('publishedPublications', $publishedPublication);