Php ZF2表单提交,无需在模式中重新加载页面,如图所示

Php ZF2表单提交,无需在模式中重新加载页面,如图所示,php,angularjs,zend-framework2,Php,Angularjs,Zend Framework2,我想在不重新加载页面的情况下提交此表单(在模式本身内部)。在验证表单之后,它应该重定向到所需页面,而不是在表单发布之后。 注意:我不想使用AJAX 非常感谢。 图为: 这是我试过的 public function listAction() { if(!$user = $this->identity()) return $this->redirect()->toRoute('user',array('action'=>'login'));

我想在不重新加载页面的情况下提交此表单(在模式本身内部)。在验证表单之后,它应该重定向到所需页面,而不是在表单发布之后。 注意:我不想使用AJAX 非常感谢。 图为:

这是我试过的

     public function listAction()
{
    if(!$user = $this->identity())
        return $this->redirect()->toRoute('user',array('action'=>'login'));
    $em = $this->getEntityManager();

    $survey = new Survey();
    $form = new SurveyForm();
    $message="Create Survey";
    $surveyList = $em->getRepository('Easysurvey\Entity\Survey')->findall();

    $form->get('submit')->setValue('Save & Add Question');

    $form->setHydrator(new DoctrineHydrator($em,'Easysurvey\Entity\Survey'));
    $form->bind($survey);

    //add new       
    $request = $this->getRequest();
    if ($request->isPost()) {
        $data = $request->getPost();

            $form->setInputFilter(new SurveyFilter($this->getServiceLocator()));
            $form->setData($data);

            if ($form->isValid()) {
                $this->prepareData($survey);

                $this->flashMessenger()->addSuccessMessage('succesfully created');
                $em->persist($survey);
                $em->flush();

                    return $this->redirect()->toRoute('survey', array('action' => 'list'));
            }
        }
    }
    return array('form' => $form,
                    'surveyList' => $surveyList,
                        'message' => $message

    );
}
list.phtml:

                                <!-- Create Modal -->
      <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-lg">
       <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title" id="myModalLabel"><?php echo $message?></h4>
        </div>
        <div class="modal-body">
            <?php
                $form->setAttribute('action', $this->url('survey', array('action' => 'list')),'class','form-horizontal');
                $form->prepare();

                echo $this->form()->openTag($form);
                echo $this->formHidden($form->get('id'));
                echo $this->formRow($form->get('name'));
                echo '<br />';
                echo $this->formRow($form->get('description'));
                echo '<br />';
                echo $this->formRow($form->get('startdate'));
                echo '<br />';
                echo $this->formRow($form->get('enddate'));
                echo '<br />';
                echo $this->formRow($form->get('createdby'));
                echo '<br />';
                echo $this->formSubmit($form->get('submit'));
                echo $this->form()->closeTag();
            ?>
        </div>
        <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close </button>
        </div>
    </div>
</div>

&时代;
接近

您需要javascript,Jquery使ajax调用非常简单,基本上:

获取url:$('form.form horizontal').attr('action')

然后,在执行请求后调用的回调函数上,隐藏引导模式,并有选择地向最终用户显示成功消息


太好了,如果您尝试的内容有任何问题,请告诉我们。当我按下提交按钮时,它会重定向,因此模式会消失。我想保留模态直到我的表格没有生效..给我们看看你尝试了什么。所以不是免费工作。正如你所说,我添加了动作部分。还有什么需要的吗?实际上你不明白我的问题。谢谢你#代达罗斯,我建议你检查一下,尽管那篇文章的重要部分主要是以下几点:为了给你一个适合你的答案,我们需要知道你尝试了什么,为什么它不适合你。这样我们就不会给您提供不适合您的情况的解决方案。你已经提供了一个“没有ajax”,但我们需要更多。用户在他们的帖子中说ajax是不可能的。这就像没有css的网站样式一样。不是真的,甚至不接近。不管怎样,这都是OP的要求。