[symfony-users] Re: sfForm-save() for an update
Using both solutions getting following error.. Cannot insert a value for auto-increment primary key [Profile.ID] :( On Mon, Aug 31, 2009 at 6:00 PM, Alexandre SALOME alexandre.sal...@gmail.com wrote: 2 solutions : - check the id field is set and be sure it is rendered in form (hidden field : $form-renderHiddenFields()) - Add id to parameters : $this-form-bind(array_merge(array('id' = $id), $request-getParameter($this-form-getName(; Good luck 2009/8/31 krishan milepe...@gmail.com Friends I am facing a problem for updating a record in table in many steps. In each step I save the submitted data. This is my code $this-form = new ProfileForm(); $this-form-bind($request-getParameter($this-form-getName())); if ($this-form-isValid()) { $this-form-setOption('id', $request-getParameter('id')); $php_profile = $this-form-save(); } when I run $this-form-save(); function it adds a new record in database. But I want it to update the record provided with the id. Does anyone knows how to do that. I tried o use $this-form-setNew (false); but does not work with $this object... -- Alexandre Salomé -- alexandre.sal...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: sfForm-save() for an update
For this to work, you'll have to find existing records first and then use it while building the form object. -- $profile = "">Profile')-find($request-getParameter('id')); $this-form = new ProfileForm($profile); $this-form-bind($request-getParameter($this-form-getName())); if ($this-form-isValid()) { $php_profile = $this-form-save(); } -- Thanks Avnish Original Message ---- Subject: [symfony-users] Re: sfForm-save() for an update From: Krishan .G milepe...@gmail.com To: symfony-users@googlegroups.com Date: Thursday 03 September 2009 02:31 PM Using both solutions getting following error.. Cannot insert a value for auto-increment primary key [Profile.ID] :( On Mon, Aug 31, 2009 at 6:00 PM, Alexandre SALOME alexandre.sal...@gmail.com wrote: 2 solutions : - check the id field is set and be sure it is rendered in form (hidden field : $form-renderHiddenFields()) - Add id to parameters : $this-form-bind(array_merge(array('id' = $id), $request-getParameter($this-form-getName(; Good luck 2009/8/31 krishan milepe...@gmail.com Friends I am facing a problem for updating a record in table in many steps. In each step I save the submitted data. This is my code $this-form = new ProfileForm(); $this-form-bind($request-getParameter($this-form-getName())); if ($this-form-isValid()) { $this-form-setOption('id', $request-getParameter('id')); $php_profile = $this-form-save(); } when I run $this-form-save(); function it adds a new record in database. But I want it to update the record provided with the id. Does anyone knows how to do that. I tried o use $this-form-setNew (false); but does not work with $this object... -- Alexandre Salom -- alexandre.sal...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: sfForm-save() for an update
Thank you Avnish, I got that, But is there some other way in which we do not need to retrieve record first and then update. I know one which is by using $form = new Profile() and then using $form-setNew(false) for update, instead of using new ProfileForm object. But I was not able to verify the value using $form-isValid(). Is it possible to make form validation this way that ProfileForm (sForm) object does? On Thu, Sep 3, 2009 at 6:32 PM, Avnish Pundir avnish.pun...@tekmindz.comwrote: For this to work, you'll have to find existing records first and then use it while building the form object. -- $profile = Doctrine::getTable('*Profile* ')-find($request-getParameter('id')); $this-form = new ProfileForm($profile); $this-form-bind($request-getParameter($this-form-getName())); if ($this-form-isValid()) { $php_profile = $this-form-save(); } -- Thanks Avnish Original Message Subject: [symfony-users] Re: sfForm-save() for an update From: Krishan .G milepe...@gmail.com milepe...@gmail.com To: symfony-users@googlegroups.com Date: Thursday 03 September 2009 02:31 PM Using both solutions getting following error.. Cannot insert a value for auto-increment primary key [Profile.ID] :( On Mon, Aug 31, 2009 at 6:00 PM, Alexandre SALOME alexandre.sal...@gmail.com wrote: 2 solutions : - check the id field is set and be sure it is rendered in form (hidden field : $form-renderHiddenFields()) - Add id to parameters : $this-form-bind(array_merge(array('id' = $id), $request-getParameter($this-form-getName(; Good luck 2009/8/31 krishan milepe...@gmail.com Friends I am facing a problem for updating a record in table in many steps. In each step I save the submitted data. This is my code $this-form = new ProfileForm(); $this-form-bind($request-getParameter($this-form-getName())); if ($this-form-isValid()) { $this-form-setOption('id', $request-getParameter('id')); $php_profile = $this-form-save(); } when I run $this-form-save(); function it adds a new record in database. But I want it to update the record provided with the id. Does anyone knows how to do that. I tried o use $this-form-setNew (false); but does not work with $this object... -- Alexandre Salomé -- alexandre.sal...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---
[symfony-users] Re: sfForm-save() for an update
2 solutions : - check the id field is set and be sure it is rendered in form (hidden field : $form-renderHiddenFields()) - Add id to parameters : $this-form-bind(array_merge(array('id' = $id), $request-getParameter($this-form-getName(; Good luck 2009/8/31 krishan milepe...@gmail.com Friends I am facing a problem for updating a record in table in many steps. In each step I save the submitted data. This is my code $this-form = new ProfileForm(); $this-form-bind($request-getParameter($this-form-getName())); if ($this-form-isValid()) { $this-form-setOption('id', $request-getParameter('id')); $php_profile = $this-form-save(); } when I run $this-form-save(); function it adds a new record in database. But I want it to update the record provided with the id. Does anyone knows how to do that. I tried o use $this-form-setNew (false); but does not work with $this object... -- Alexandre Salomé -- alexandre.sal...@gmail.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~--~~~~--~~--~--~---