EllisLab text mark
Advanced Search
     
Call to undefined function validation_errors() problem
Posted: 08 October 2012 03:17 PM   [ Ignore ]
Joined: 2012-09-29
5 posts

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:

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

<?php 

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


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

<
div><input type="submit" value="Submit" /></div

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

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

And my index controller goes something like this:

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');
  
}


 

 
Posted: 08 October 2012 03:36 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3819 posts

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”.

 Signature