Welcome Guest, Not a member yet? Register   Sign In
Call to undefined function validation_errors() problem
#1

[eluser]razorsese[/eluser]
I try to integrate in my main view file a form with its specific controller and view but i'm missing something therefore i get validation_errors()in views\formaddbook.php.

addbookmark.php:

Code:
class addbookmark extends CI_Controller
{



  
   function index()
   {
    
    
     $this->bookmark_add();
     $this->load->view('formaddbook');

   }




   public function bookmark_add()
   {

       $this->load->helper(array(
            'form',
            'url'
        ));


      
        $this->load->library('form_validation');
        
      
        
        $this->form_validation->set_rules('bookmark', 'Bookmark', 'trim|required|min_length[5]|max_length[12]|xss_clean');




   }





}


formaddbook.php
Code:
<?php

echo validation_errors();
echo form_open('addbookmark');
?>


<input type="text" name="bookmark" value="<?php echo set_value('bookmark'); ?>" size="50" />

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

And in my index_view.php i try to load with following code:

Code:
$this->load->view('formaddbook');

And my index controller goes something like this:

Code:
class index extends CI_Controller{

     public function __construct()
{
    parent::__construct();

    
     $this->load->helper('url');

     $this->check_log();
}




  function index()
{
      


       $this->db->select('id','bookmark');

       $query = $this->db->get('bookmarks');

      $this->load->view('index_view',$query);
  
}

  public function check_log()
  {
      

    if ( $this->session->userdata('log') == TRUE ) {
    echo $this->session->userdata('username');
    }



  }

  function addbook()
  {

    $this->load->view('formaddbook');
  }




}
#2

[eluser]CroNiX[/eluser]
I'm not sure why you're doing some of what you're doing, or why you're doing it the way you are, but in your index/addbook, you aren't loading the form helper but are loading the view that uses it.

I also wouldn't name a controller "index".




Theme © iAndrew 2016 - Forum software by © MyBB