Comments (6)
Looks like its still an issue.
I have entity Comment and Comments Thread
class CommentsThread { /** * @var integer $id * * @ORM\Column(name="id", type="integer", nullable=false) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; /** * @var integer $commentsCounter * * @ORM\Column(name="comments_counter", type="integer", nullable=false) */ protected $commentsCounter = 0; /** * @var boolean $isCommentsEnabled * * @ORM\Column(name="is_comments_enabled", type="boolean", nullable=false) */ protected $isCommentsEnabled = true; /** * @ORM\OneToMany(targetEntity="ACME\BUNDLE\Entity\Comment", mappedBy="commentsThread", cascade={"all"},orphanRemoval=true) */ public $comments;
I show related comments in commentsThread admin with code like
class CommentsThreadAdmin extends Admin { protected function configureFormFields(FormMapper $formMapper) { $formMapper ->with('GeneralSection') ->add('comments','sonata_type_collection', array('by_reference' => false), array('edit' => 'inline','inline' => 'table','targetEntity'=>'Vido\CoreBundle\Entity\Comment')) ->add('isCommentsEnabled','checkbox',array('required'=>false)) ->end() ; }
and related commentAdmin
class CommentAdmin extends Admin { protected function configureFormFields(FormMapper $formMapper) { $formMapper ->with('GeneralSection') ->add("createdUser") ->add("createdAt") ->add('body',null, array('required'=>true)) ->end() ; }
Update function works great :)
But when I select checkbox near some comment I got error
[1/2] PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`articles`, CONSTRAINT `FK_BFDD3168A16B7634` FOREIGN KEY (`comments_thread_id`) REFERENCES `comments_threads` (`id`)) at PDOStatement ->execute (array('2')) in \vendor\doctrine-dbal\lib\Doctrine\DBAL\Connection.php at line 709 at Connection ->executeUpdate ('DELETE FROM comments_threads WHERE id = ?', array('2')) in \vendor\doctrine-dbal\lib\Doctrine\DBAL\Connection.php at line 432 -+
So its actually try to delete commentThread itself instead of checked for deletion comment :(
from sonataadminbundle.
This issue can be solve by using the related entity manager to delete/save/update the related object
from sonataadminbundle.
thanks for suggestion, but I dont get you though :(
Lets say, I have
Article with sonata_type_admin item of CommentsThread which have sonata_type_collection with Comments.
Near each comment there are checkbox for comments deletion.
When I check checkbox near comment entity - CommentsThread delete query created, which is wrong.
It seems to be a bug.
from sonataadminbundle.
The comment is about how to implement the fix in the AdminBundle.
from sonataadminbundle.
maybe Zhil has solved his issue but for those that are wondering:
/**
* {@inheritdoc}
*/
public function setGalleryHasMedias($galleryHasMedias)
{
foreach ($galleryHasMedias as $galleryHasMedia) {
$galleryHasMedia->setGallery($this);
}
$this->galleryHasMedias = $galleryHasMedias;
}
this is the snippet you need. You must implement the setRelated in your parent Entity like this and it starts working.
from sonataadminbundle.
@rande Can you check this old issue?
from sonataadminbundle.
Related Issues (20)
- Datepicker calendar window is placed incorrectly if the field is at the bottom HOT 1
- Unable to use a custom message to be shown as the error flash message HOT 2
- admin-lte js package 2.4 is concerned by known critical vulnerabilities HOT 5
- Customizable breadcrumbs HOT 1
- ChoiceFieldMaskType with expanded: true does not work well when icheck is disabled HOT 2
- ModelList btn_delete bug when hit Enter key HOT 2
- Allow customize sonata-admin webpack build(s) HOT 1
- Rebuild template layer HOT 6
- Submitting a form with ->render instead of ->renderWithExtraParams does not work HOT 9
- Security threat within symfony/twig-bridge HOT 3
- SAML SSO and SCIM to the Admin Panel HOT 2
- Using SubClasses in admins create either not handable translation ids or urly urls HOT 2
- Overriding createQuery doesn't seem to be a thing anymore HOT 2
- symfony 7 compatibility HOT 1
- Problem 1 - symfony/security-acl[v3.1.0, ..., v3.1.2] require symfony/security-core ^3.4|^4.4|^5.0 -> found symfony/security-core[v3.4.0, ..., v3.4.49, v4.4.0, ..., v4.4.48, v5.0.0, ..., v5.4.30] but it conflicts with your root composer.json require (7.0.*). HOT 2
- Customise error message for ModelManagerException HOT 1
- CSRF token error occurs on record creation after applying symfony/security-http security patch HOT 4
- `Uncaught TypeError: __webpack_require__.O is not a function` after upgrading to a version >=4.24.0 HOT 8
- List add item using inline form
- The name "Doctrine\ODM\MongoDB\ArrayCollectionelements" contains illegal characters. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sonataadminbundle.