mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3772: ORM\PreFlush() not Persisted in Database but return right value in my form #4623
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Jun 15, 2015).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user zagloo:
I have a problem with a Preflush() method.
When I valid my form, my form return to me the values that expected but they are not persisted into the database in the case where I create a new Entity.
to a better understand for you, all files that I'm using are in this Gist :
https://gist.github.com/zagloo/1eaedffc2f479686d98f
I have 2 Entities :
These 2 Entities have these relation between them :
Then I my controller TestController, I create a form with «FirstType_» and «_OtherType» and render it in test_preflush,html,twig
Feature of my form : I'm using a custom textarea named «**textarea_test_» thanks to a TestType_ which using a Transformer TestTranformer.
This Transformer allows to transform a *PersistCollection* in a String and conversely with the reverseTransform.
In the Transformer **TestTranformer_, public function transform($value) method concatenate each field3_ from Other Entity in
Vsual example :
Database for «First» Entity
!https://cloud.githubusercontent.com/assets/8613226/8109975/fece771a-1059-11e5-9660-eb5d10b511ca.png!
Database for «Other» Entity
!https://cloud.githubusercontent.com/assets/8613226/8109983/09b3beb0-105a-11e5-95c9-f7b741e8ed7d.png!
The render in twig of the form with the transformer :
!https://cloud.githubusercontent.com/assets/8613226/8109988/0f6b1f7e-105a-11e5-9df0-ceae54c0bfd3.png!
Until here, no problem, I have what I expected, a textarea with a concatenation of field3 !
Then, if I modify a value, no problem, the *PreFluch()* contained at the end of «First» Entity works.
-> value of *field3* for the first entity Other is changed by "toto" in database and returned right in my twig form !
Database for «Other» Entity
!https://cloud.githubusercontent.com/assets/8613226/8110399/594e9056-105c-11e5-964f-3c73e1121f7f.png!
The render in twig of the form with the transformer :
!https://cloud.githubusercontent.com/assets/8613226/8110397/570743ce-105c-11e5-8906-c693d527bf0b.png!
Now, here is my PROBLEM !
I delete all in my textarea and add a new *
!https://cloud.githubusercontent.com/assets/8613226/8110833/9e0639f4-105e-11e5-9d75-a64ffb035544.png!
Normally, my *Reversetransformer* create a new Other() and set value into it. (see TestTransformer Gist from the line 55).
But when I valid the form, in return, in my twig I get a good text area with *
My twig (Good return)
!https://cloud.githubusercontent.com/assets/8613226/8110743/46b190e0-105e-11e5-91c1-e594df12b00c.png!
My Database Other Entity
!https://cloud.githubusercontent.com/assets/8613226/8110776/6f523c52-105e-11e5-9463-cf6811ba95b1.png!
TO RESUME,
if I just modify values in text area, no problem
=> toto is persisted in database and return in my form twig.
But if I add a new field3, toto is returned into my twig (good!) but not persisted into the database (not good....!!)...
Where is the problem please ? (and sorry for my english)
For Information , here are the different versions that I'm using thanks to the command composer show -i in the console of my IDE :
For Symfony :
symfony/symfony v2.7.0 The Symfony PHP framework
For Doctrine :
doctrine/annotations v1.2.4 Docblock Annotations Parser
doctrine/cache v1.4.1 Caching library offering an object-oriented API for many cache backends
doctrine/collections v1.3.0 Collections Abstraction library
doctrine/common v2.5.0 Common Library for Doctrine projects
doctrine/data-fixtures v1.1.1 Data Fixtures for all Doctrine Object Managers
doctrine/dbal v2.4.4 Database Abstraction Layer
doctrine/doctrine-bundle v1.5.0 Symfony DoctrineBundle
doctrine/doctrine-cache-bundle v1.0.1 Symfony2 Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle dev-master c5ff054 Symfony DoctrineFixturesBundle
doctrine/inflector v1.0.1 Common String Manipulations with regard to casing and singular/plural rules.
doctrine/lexer v1.0.1 Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm v2.4.7 Object-Relational-Mapper for PHP