you might want to have a look to swToolboxPlugin [1], there is a function to define only fields you want. The method will remove all non specify fields [1] http://trac.symfony-project.org/browser/plugins/swToolboxPlugin/tags/VERSION_1_2_6/lib/form/swToolboxFormHelper.class.php#L283
On Tue, Jul 14, 2009 at 7:01 PM, Mushing Fan <[email protected]> wrote: > > Well, if this cannot be fixed in Symfony, does anyone see bad > consequences to override the bind method in the BaseFormDoctrine class > like this: > > public function bind(array $taintedValues = null, array > $taintedFiles = null) > { > parent::bind($taintedValues, $taintedFiles); > > foreach ($this as $name => $widget) { > if (!isset($taintedValues[$name])) > unset($this[$name]); > } > } > > This would remove from the bound values any field that was not part of > the post and fix the data loss problem described above. > > On Jul 13, 1:55 pm, Mushing Fan <[email protected]> wrote: > > There was another problem that this fix corrected which is data loss > > when the field that you forget to unset is a m2m list. > > In that case, when you do not unset the field in the form but you do > > not have it in the display section of the generator.yml file, Symfony > > will remove all the existing m2m relations for that record when the > > form is saved, at least for Doctrine. > > > > I had this (painful) data loss happen a couple of time before I > > realized it was due to the fact of not unsetting a m2m list field. > > > > I understand it is the developer's responsibility to unset the field > > in the form as well as setting it in the generator.yml, but data loss > > is quite a heavy punishment for forgetting to do it. > > > > What doe not seem logical is that records get deleted based on > > information that is not part of the post (the m2m list in this case). > > > > Would it make sense when the form is bound in the update action, that > > only the fields that are actually part of the post remain for the > > update or is that stupid? > > > > On Jul 13, 10:50 am, Fabian Lange <[email protected]> > > wrote: > > > > > Dear devs, > > > I just released symfony 1.2.8. Please head over to my blog post for > > > more details: > http://www.symfony-project.org/blog/2009/07/13/symfony-1-2-8-rolling-... > > > > > Fabian > > > -- Thomas Rabaix http://rabaix.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en -~----------~----~----~----~------~----~------~--~---
