eav-manager icon indicating copy to clipboard operation
eav-manager copied to clipboard

Adding values to a multiple fields is not working

Open johnkrovitch opened this issue 5 years ago • 3 comments

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: []
}

johnkrovitch avatar Nov 19 '19 14:11 johnkrovitch

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...

johnkrovitch avatar Nov 19 '19 14:11 johnkrovitch

This is not normal and should be working as expected with the 2 syntax

VincentChalnot avatar Nov 19 '19 14:11 VincentChalnot

It should also work like this:

$publication->add('publishedPublications', $publishedPublication);

VincentChalnot avatar Nov 19 '19 14:11 VincentChalnot