CodeIgniter 中未显示验证闪存数据错误

Validation flashdata error is not displaying in CodeIgniter

这是我在控制器中的登录方法,在这里我为验证错误设置了一个闪现消息 -

public function login(){
    $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[3]');
    $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[3]');

    if($this->form_validation->run() == FALSE){
        $data = array(
          'errors' => validation_errors()
        );
        $this->session->set_flashdata($data);
        redirect('home');
    }
}

这里是显示这些错误的代码 -

<?php if($this->session->flashdata('errors')): ?>
    <?php echo $this->session->flashdata('errors');?>

<?php endif; ?>

不知道怎么回事,没有显示错误信息。

我希望完成这个过程

if($this->form_validation->run() == FALSE){
    $this->session->set_flashdata('name','Your message');
    redirect('home');
}
<?php if($this->session->flashdata('name')): ?>
<?php echo $this->session->flashdata('name');?>    
<?php endif; ?>

放在控制器中

if ($this->form_validation->run() == FALSE) {       
$errors = validation_errors();
           $this->session->set_flashdata('form_error', $errors);
           $this->load->view('Your View page');
}

已放入您的查看页面

<?php if($this->session->flashdata('form_error')): ?>
    <?php echo $this->session->flashdata('form_error');?>

<?php endif; ?>

希望对你有所帮助..!