CakePHP 不显示 flash() 消息?

发布于 2024-09-10 05:41:49 字数 251 浏览 1 评论 0原文

我正在编写一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空宴 2024-09-17 05:41:49

在您看来&布局,您正在寻找会话帮助器,而不是您尝试使用的会话组件。在控制器/组件中,您使用会话组件并将其引用为 $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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文