0

validation_errors() からのエラーを変数に保存し、ビューに表示したい。

ビューに変数を渡して別のビューを渡す方法を知っています:

コントローラーで:

$data['date'] = 'some_data';
$this->load->view('register/register_open',$data);

in 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() を配列または変数に保存してからビュー ページに渡す方法がわかりません。私たちを手伝ってくれますか?

4

1 に答える 1

0

このマニュアルを参照してください: 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);

データ構造とその処理方法を理解できます。

于 2012-10-26T11:50:13.880 に答える