[英]Open bootstrap modal after failed submit
I got a login/register form in a modal. 我收到了模态的登录/注册表格。 And after the submit failed and the page reloaded, I want to open the form again and add a second modal below the login modal.
提交失败并重新加载页面后,我想再次打开表单,并在登录模式下方添加第二个模式。
My code doesn't work: 我的代码不起作用:
if ($this->getRequest()->isPost())
{
$form->setData($this->getRequest()->getPost());
/** @var \Zend\Authentication\Adapter\DbTable $Adapter */
if ($form->isValid())
{
$data = $form->getData();
$Adapter = $this->authService->getAdapter();
$Adapter
->setIdentity($data['email'])
->setCredential($data['password']);
$authResult = $this->authService->authenticate();
if (!$authResult->isValid())
{
echo "<script>
$(document).ready(function(){
alert('hi');
});
</script >";
}
else
{
return $this->redirect()->toRoute("blog");
}
}
else
{
return new ViewModel(
[
'form' => $form,
]
);
}
}
As of you're doing an redirect ( return $this->redirect()->toRoute("blog");
) to another route, your "echo" doesn't render. 在您进行重定向(
return $this->redirect()->toRoute("blog");
)返回到另一条路由时,您的“ echo”不会呈现。 The new HTML of new Route will render. 将呈现新Route的新HTML。
So your echo has to be in the new route (may via an Parameter) 因此,您的回声必须在新路径中(可能通过参数)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.