Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter form validation error message does not display [closed]

my form validation error does not show messages in view file when i load model and get row from tables. here is my code.

        $this->form_validation->set_rules('bookCategoryId', 'Book SubCategory Id', 'trim|required');
        $this->form_validation->set_rules('bookSubCategoryId', 'Book SubCategory Id', '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);
    }

My form works fine if i exclude these two line

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

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

than my validations shows error. I dont know where is the problem ?

like image 795
Aneeq Tariq Avatar asked Sep 02 '13 12:09

Aneeq Tariq


1 Answers

You should use validation_errors function

<?php echo validation_errors(); ?>

Documentation 3.x: validation_errors

Documentation 2.x: form_validation

like image 130
Bora Avatar answered Nov 14 '22 22:11

Bora