0

I've created an entity that I can't update using doctrine-generated form. Here's an action:

    public function executeEdit(sfWebRequest $request)
{

    $this->forward404Unless($id = $request->getParameter('id'), "Required parameter 'id' must be present in request");

    $this->forward404Unless($cart = Doctrine::getTable('ShoppingCart')->find($id), sprintf("No object could be retrieved by %s", $id));
    $this->id = $id;

    $this->form = new ShoppingCartForm($cart);

    if($request->isMethod(sfRequest::POST)) {
        $this->form->bind($request->getParameter('shopping_cart'));
        if ($this->form->isValid())
        {
            $cart = $this->form->save();

            $this->redirect(link_to('cart/show?id='.$cart->getId()));
        }
    }
}

Form's isNew() method returns false, but the sf_method is set to PUT. When I use sfRequest::PUT doctrine tries to add new entity with that id. It seems like it shouldn't behave like that so what I am doing wrong?

4

0 回答 0