SonataAdminBundle: Symfony 2.6.13 Sonata-Admin sonata_type_collection is breaking form
I’m using sonata_type_collection to create multiple inline photos for page:
$formMapper
->add('title', 'text', array('label' => 'Page title'))
->add('images','sonata_type_collection', array('label' => 'Images'), array(
'edit' => 'inline',
'inline' => 'table',
))
When I’m saving form I have the following error:
Extra fields are not allowed
Probably, because this is OneToMany relationship
/**
* @ORM\OneToMany(targetEntity="(..)\Image", mappedBy="page", cascade={"all"}, orphanRemoval=true)
*/
protected $images;
Doctrine doesn’t understand that something’s changed and therefore it doesn’t call prePersist/preUpdate.
public function preUpdate($product)
{
die("Here"); // Doesn't die here.
$product->setPhotos($product->getPhotos());
}
Maybe this is a reason? If so, how can I fix that?
When I’m trying to save form without any photos attached, it works flawlessly.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 59 (34 by maintainers)
If you think it is after an upgrade, you could try pin pointing the faulty commit with git bisect
Unfortunately it’s more complicated 😃
@meesix This is typically the kind of scenario in which I end up using a debugger…