$ this-> Flash-> success(__('用户已被保存。'));不工作的cakephp 2.X

问题描述 投票:-1回答:1

我想在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(); ?>

任何人?谁可以告诉我为什么它不工作的确切问题..

php cakephp cakephp-2.0 flash-message
1个回答
0
投票

在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

© www.soinside.com 2019 - 2024. All rights reserved.