【问题标题】:$this->Flash->success(__('The user has been saved.')); not working cakephp 2.X$this->Flash->success(__('用户已被保存。'));不工作 cakephp 2.X
【发布时间】:2017-12-20 13:32:29
【问题描述】:

我正在尝试在 cakephp2 中使用 Flash 组件

我已经声明了组件

public $components = array('Paginator', 'Session', 'Flash');

然后尝试在控制器中设置 Flash 消息:

$this->Flash->error('The cashpickup could not be saved. Please, try again.'); // To display error
$this->Flash->success(__('The user has been saved.')); // to display success

在视图中,我正在使用以下代码:

<?php echo $this->Flash->render(); ?>

有人吗?谁能告诉我为什么它不起作用的确切问题..

【问题讨论】:

  • “不工作”这是什么意思?您需要在此处提供更多信息。
  • @mark 视图中没有显示 Flash 消息

标签: php cakephp cakephp-2.0 flash-message


【解决方案1】:

在 app/View/Elements/Flash/success.ctp 中

<div id="flash-<?php echo h($key) ?>" class="message-info success">
    <?php echo h($message) ?>: <?php echo h($params['name']) ?>, <?php echo h($params['email']) ?>.
</div>

参考https://book.cakephp.org/2.0/en/core-libraries/components/flash.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-15
    • 1970-01-01
    相关资源
    最近更新 更多