Search code examples
phpvariables

validation_errors(), variable,


I want to save errors from validation_errors() in variable, and dispay it in view.

I know how I can pass variable to view pass another view:

in controller:

$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');
?>

in view:

 <?php echo $date; ?>

But I don`t know how can I save validation_errors() in array or variable, and pass then to view page. Could you help me?


Solution

  • See this manual: http://ellislab.com/codeigniter/user_guide/general/views.html

    Assigning variable:

    <?php
    class Blog extends CI_Controller {
    
        function index()
        {
            $data['title'] = "My Real Title";
            $data['heading'] = "My Real Heading";
    
            $this->load->view('blogview', $data);
        }
    }
    ?>
    

    Now using it in view as:

    <html>
    <head>
    <title><?php echo $title;?></title>
    </head>
    <body>
        <h1><?php echo $heading;?></h1>
    </body>
    </html>
    

    In your case, try this in view:

    var_dump($todo_list);
    

    You will understand the data structure and how to process it.