开发者

form submitting in ajax and symfony validations

i got problem that when i submit form in jquery/ajax i get the data and check isvalid or not and save it. but wen the form is not valid it does not do symfony validations it automatically redirect to the page with out saving anything...the prob is it check the validation but it does not display validation error instead it simply redirected.

//my action code
public function executeAjaxtest(sfWebRequest $request)
{
  if ($request->isXmlHttpRequest())
  {
    if($request->isMethod('post'))
    {
      $this->form = new UserForm();
      $this->form->bind(
        $request->getParameter($this->form->getName()),
        $request->getFiles($this->form->getName())
      );
      if ($this->form->isValid())
      {
        $this->form->save();
        $this->redirect('registration/ajaxtest');
      }
    }
  }开发者_C百科
}


your code looks having no issue. you should check with save method. Jus overwrite save method and check.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜