【发布时间】:2017-01-05 16:43:53
【问题描述】:
我有一个模态的登录/注册表单。在提交失败并重新加载页面后,我想再次打开表单并在登录模式下方添加第二个模式。
我的代码不起作用:
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,
]
);
}
}
【问题讨论】:
-
由于您没有显示太多代码,您能否在您的
<script>标签之后插入alert('hi');?无效登录后是否会在页面重新加载时提醒您? -
@lippoliv 警报不起作用
-
所以你知道:你的 PHP 不会渲染脚本。愿您向我们展示更多您的 PHP 代码,以便我们为您提供帮助。
-
@lippoliv 我添加了更多代码,但我不确定这是否会对您有所帮助
-
您的代码肯定不可读。在 laravel 路由中,您不必检查帖子。只需添加一个 POST-Routing,没有 GET-Routing 和 laravel 会为你做检查。您能否将您的
echo替换为dd调用以查看您的PHP 是否到达该代码行?
标签: jquery twitter-bootstrap bootstrap-modal