CakePHP 不显示 flash() 消息?
我正在编写一个 CakePHP 应用程序,但它似乎没有在任何页面上显示 flash() 消息。
我使用 $this->Session->setFlash();
设置 flash() 消息并使用 $this->Session->flash()
在我的默认模板中,以及登录和注册页面上的 $this->Session->flash('auth')
但它们不显示验证错误等。
I am writing a CakePHP app but it doesn't seem to be showing flash() messages on any of the pages.
I am using $this->Session->setFlash();
to set flash() messages and using $this->Session->flash()
in my default template, as well as $this->Session->flash('auth')
on the login and registration pages but they don't show the validation errors etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您看来&布局,您正在寻找会话帮助器,而不是您尝试使用的会话组件。在控制器/组件中,您使用会话组件并将其引用为
$this->Session
。在布局和视图中,您可以使用会话帮助器并将其简单地引用为$session
。例如$session->flash();
有关 会话助手的更多信息 可以在文档中找到。
In your views & layouts, you're looking for the session helper, not the session component that you're trying to use. In controllers/components, you use the session component and reference it as
$this->Session
. In your layouts and views, you use the session helper and reference it simply as$session
. e.g.$session->flash();
More about the session helper can be found in the documentation.