php – codeigniter表单验证错误消息不显示

当我加载模型并从表中获取行时,我的表单验证错误不会在视图文件显示消息.这是我的代码.
$this->form_validation->set_rules('bookCategoryId','Book SubCategory Id','trim|required');
        $this->form_validation->set_rules('bookSubCategoryId','trim|required');
        $this->form_validation->set_rules('bookSubCategoryName','Book SubCategory Name','trim|required');
if ($this->form_validation->run() == FALSE) {
        /* Load Model */
        $this->load->model('book_category');

        /* Get Categories */
        $template_data['mainContentData']['book_categories'] = $this->book_category->get_all_categories();

        /* set view page to be called  */
        $template_data['mainContent'] = 'admin_add_book_subcategory';

        /* Load Template */
        $this->template($template_data);
    }

如果我排除这两行,我的表单工作正常

/* Load Model */
        $this->load->model('book_category');

        /* Get Categories */
        $template_data['mainContentData']['book_categories'] = $this->book_category->get_all_categories();

比我的验证显示错误.我不知道问题出在哪里?

您应该使用validation_errors函数
<?PHP echo validation_errors(); ?>

文档3.x:validation_errors

文件2.x:form_validation

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...