开发者

Can you explain why I need a new form for update function in Symfony?

I have an action that creates a form. The form's action then points to the following function:

  public function executeUpdateInlineForm(sfWebRequest $request)
{

  $overdueInvestigation = Doctrine_Core::getTable('investigation')->find( $request->getParameter('id'));    
  $this->form = new investigationInlineForm($overdueInvestigation);

  $this->processInlineForm($request, $this->f开发者_如何学编程orm);
}

What I don't understand is why I need instantiate a new form when all I am trying to do is save the existing one?

I am asking this because my form has fields from two different tables and I want to be able to update both tables when the user submits. I therefore need to work out the correct way to do this.


You're dealing with a class so you must instantiate it. When the form is submitted, your script that originally rendered the response and everything that went into it is long gone. This function doesn't know about it anymore.


The reason symfony ordinarily creates a new form upon form submission is to handle displaying the form with any invalid fields highlighted to let the user re-try.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜