[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><input type="submit" value="Submit" /></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');
}
}