未能在我的表单中显示代码点火器的错误


Fail to show an error in my form with codeigniter

这是我的控制器:

    public function Index()
{
     $this->load->model('InsertData');
       $this->InsertData-> validateField();
     $this->InsertData->DispalyForm();
}

这是我的型号:

     class InsertData extends CI_Model
 {
     function __construct() {
         parent::__construct();
         $this->load->helper('form');
     }
     function DispalyForm()
     {
            $dataI = array(
                'name'        => 'topic',
                'id'          => 'url',
                'value'       => set_value('username'),
                'maxlength'   => '100',
                'size'        => '50',
                'style'       => 'yellow',
                );
            $dataS=array(
                'name' => 'submit',
                'value'=>'create topic'
            );
            $data['submit'] = form_submit($dataS);
            $data['textbox']= form_input($dataI);
            $this->load->view('admin',$data);
     }
     function validateField()
     {
         $this->load->library('form_validation');
         $rules['topic']='required';
         $this->form_validation->set_rules($rules);
         $this->form_validation->run();

   }
 }

问题是,每当我提交表单时,字段为空,就不会显示任何内容。

我在我的视图顶部有这样一行:

       <?php echo validation_errors(); ?>

我的代码哪里错了。。为什么我提交表单时没有显示错误?!!?

使用数组设置验证规则时,数组必须是多维的。

一组规则,其中每个规则都是一组标准。

请参阅本手册第页,了解此问题。

$rules = array(
    array(
         'field'   => 'topic', 
         'label'   => 'Topic', 
         'rules'   => 'required'
    )
);
$this->form_validation->set_rules($rules);