【问题标题】:form submitting in ajax and symfony validations在 ajax 和 symfony 验证中提交表单
【发布时间】:2011-09-10 09:35:53
【问题描述】:

我遇到的问题是,当我在 jquery/ajax 中提交表单时,我会获取数据并检查是否有效并保存。但是当表单无效时它不进行 symfony 验证它会自动重定向到页面而不保存任何内容...问题是它检查验证但它不显示验证错误而是简单地重定向。

//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');
      }
    }
  }
}

【问题讨论】:

    标签: php ajax jquery symfony1 symfony-1.4


    【解决方案1】:

    您的代码看起来没有问题。 你应该检查保存方法。只需覆盖保存方法并检查。

    【讨论】:

    • 嗨,富兰克林 .. 这个问题早就解决了。谢谢你的回答。
    • 请在收到答案时提​​及您的答案。dnt 保持原样。
    猜你喜欢
    • 2021-02-19
    • 1970-01-01
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-25
    相关资源
    最近更新 更多