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 ?
You should use validation_errors function
<?php echo validation_errors(); ?>
Documentation 3.x: validation_errors
Documentation 2.x: form_validation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With