-
-
Save docteurklein/1497965 to your computer and use it in GitHub Desktop.
| <?php | |
| $callback = function($data = null) { | |
| if (empty($data)) { | |
| return new \PropelObjectCollection(); | |
| } | |
| return $data; | |
| }; | |
| $builder | |
| ->appendClientTransformer(new CallbackTransformer($callback, $callback)); | |
| ; |
yep sorry for the loosy feedback :)
I have a FiscalPeriod object that has many municipalities. (one to many)
I have symfony form that maps the fiscal_period.municipalities as a 'collection' type. ( by_reference = false, delete = true, add = true).
When I empty the municipalities collection( eg: en empty array in the request), the form dataMapper tries to call FiscalPeriod::setMunicipalities(array()); ( with an array),
which results in a fatal error, because setMunicipalities waits for a PropelObjectColelction.
By adding a dataTransformer that transforms empty array to PropelCollection, I avoid the error.
ok, so there is no problem here, right ?
no problem anymore. I think it could be useful to either provide this dataTransformer in a PropelCollection type or describe the problem here: http://www.propelorm.org/cookbook/symfony2/mastering-symfony2-forms-with-propel.html
interesting, I've maybe done something wrong. I'l try to dig into that.
hm can you explain me a bit more ?