开发者

Integrity constraint violation: 1062 Duplicate entry '2' for key 1 in symfony doctrine using form widgets

开发者 https://www.devze.com 2023-02-22 00:50 出处:网络
I can\'t update the form usinf formwidgets, I\'m using doctrine and symfony 1.4. Here is my code protected function processFormUpdate(sfWebRequest $request, sfForm $form){

I can't update the form usinf formwidgets, I'm using doctrine and symfony 1.4.

Here is my code


protected function processFormUpdate(sfWebRequest $request, sfForm $form){
    $form->bind($request->getParameter('tblallusers'),$request->
                 getFiles($form->getName()));
        if ($form->isValid()) {
            $logement = $form->save();

        }
        else {
            $this->getUser()->setFlash('error', 'error');
        }
}


public function executeEdit(sfWebRequest $request)
{
echo $id = $this->getRequestParameter('id');
$object = Doctrine_Core::getTable("Tblallusers")->find($id);
$this->form = new TblallusersForm($object);
}

public function executeUpdate(sfWebRequest $request)
{
echo $id = $this->getRequestParameter('id');
  $object = Doctrine_Core::getTable("Tblallusers")->find($id);
  $this->form = new TblallusersForm($object);
  $this->processFormUpdat开发者_高级运维e($request, $this->form);
}

The above code throws an error like

Integrity constraint violation: 1062 Duplicate entry '2' for key 1

Please help me out of this......


The id should be grater than zero and should be unique

0

精彩评论

暂无评论...
验证码 换一张
取 消