What symfony/Doctrine version are you using? If it's 1.3/1.4, you can use embedRelation().
Over the top of my head, I'd guess it's got something to do with you not unset()-ing the primary key of the embedded form. There was even a blog post from Fabien (I think) about this, so search Google for that. Cheers, Daniel Sent from my iPhone On Jan 5, 2010, at 2:36 AM, kierzniak <[email protected]> wrote: > I have problem during saving embed form. Someone describe it on this > site: > http://symfonyguide.wordpress.com/2009/09/28/symfony-forms-saving-process/ > my problem is connected with this part: > > "I tried to embed an sfGuardForm with this system. Saving a new object > went fine, but for some reasons, editing didn’t work. After some a l > ot > of debug, I found that it triggered a hidden validation error “An > object with the same ‘username’ already exists”. Honestly I don > ’t > really remember on which level it happened, but I think this is linked > to the fact that some methods are executed twice and shouldn’t be. > Even calling the bind() method on embedded forms seems to me to be a > redundancy. When you submit a form, doClean() deeply clean the values, > meaning even embedded forms values are passed to the validators, and > returned cleaned. So if you call bind() on an embedded form it will > call the clean method again." > > In my case when i try to save embed form i have three "inserts" to > database while should be only 2. One to sfGuardUser table and one to > my schema table PanelUser. Insert to PanelUser is doubled and i don't > know why. > > INSERT INTO sf_guard_user (algorithm, is_active, is_super_admin, > username, salt, password, created_at, updated_at) VALUES > (?, ?, ?, ?, ?, ?, ?, ?) - (sha1, 1, 0, pio.ma, > e4ebecdd99d5f1128e87b36980fcb89b, > 1744b44ee23963ecf737b33839e464b1bcb0af90, 2009-12-31 15:21:14, > 2009-12-31 15:21:14) > > INSERT INTO panel_user (sf_guard_user_id, first_name, last_name, > email_address, allegro_id) VALUES (?, ?, ?, ?, ?) - (6, Piotr, Malek, > [email protected], 12313123) > > INSERT INTO panel_user (first_name, last_name, email_address, > allegro_id) VALUES (?, ?, ?, ?) - (Piotr, Malek, [email protected], > 12313123) > > -- > > You received this message because you are subscribed to the Google > Groups "symfony users" 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-users?hl=en > . > > -- You received this message because you are subscribed to the Google Groups "symfony users" 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-users?hl=en.
