我希望将validation_errors()中的错误保存在变量中,并在视图中显示它。
我知道如何将变量传递给视图传递另一个视图:
在控制器中:
$data['date'] = 'some_data';
$this->load->view('register/register_open',$data);在view_open中
<?php
$this->load->view('mains/header');
$this->load->view('login/loggin');
$this->load->view('mains/menu');
$this->load->view('left_column/left_column_before');
$this->load->view('left_column/menu_left');
$this->load->view('left_column/left_column');
$this->load->view('center/center_column_before');
$this->load->view('register/register_view');
$this->load->view('center/center_column');
$this->load->view('right_column/right_column_before');
$this->load->view('right_column/right_column');
$this->load->view('mains/footer');
?>视图中:
<?php echo $date; ?>但我不知道如何将validation_errors()保存在数组或变量中,然后传递给视图页面。你能帮我一下吗?
发布于 2012-10-26 19:50:14
请参阅此手册:http://ellislab.com/codeigniter/user_guide/general/views.html
赋值变量:
<?php
class Blog extends CI_Controller {
function index()
{
$data['title'] = "My Real Title";
$data['heading'] = "My Real Heading";
$this->load->view('blogview', $data);
}
}
?>现在,在视图中使用它作为:
<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<h1><?php echo $heading;?></h1>
</body>
</html>在您的情况下,在视图中尝试执行以下操作:
var_dump($todo_list);您将了解数据结构以及如何处理它。
https://stackoverflow.com/questions/13085883
复制相似问题