Can you post your controller's code?
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Dashboard extends CI_Controller {
private $user_data;
function __construct(){
parent::__construct();
$this->load->database();
$this->load->library('grocery_CRUD');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->model('model_login');
$this->load->view("adminstar/header");
$this->user_data = $this->session->userdata;
$now = time();
$expired = $this->session->userdata('expired');
if($now < $expired)
{
if ($this->session->userdata('username') == FALSE)
{
redirect('adminstar/admin/logout');
}
}
else
{
redirect('adminstar/admin/logout');
}
}
function index()
{
$this->load->view("adminstar/dashboard");
$this->load->view("adminstar/footer");
}
function _home_output($output = null){
$output->userinfo = $this->user_data;
$this->load->view('adminstar/crud',$output);
$this->load->view("adminstar/footer");
}
function content()
{
$crud = new grocery_CRUD();
$crud->set_model('MY_grocery_Model');
$crud->set_primary_key('menu','star_menu');
$crud->set_table('star_content');
$crud->columns('menu','title','image','publish','createdt','createby','modifieddt','modifiedby');
$crud->set_subject('Content');
$crud->display_as('ID_cat','Category');
$crud->set_relation('menu','star_menu','menu');
$crud->set_primary_key('ID','star_menu');
$crud->required_fields('title','content','publish');
$crud->set_field_upload('image','assets/uploads/img');
$crud->field_type('publish','dropdown',
array(1 => 'Publish Content', 2 => 'Disable Content'));
$this->HiddenField($crud);
$output = $crud->render();
$this->_home_output($output);
}
// function category_content()
// {
// $crud = new grocery_CRUD();
// $crud->set_table('star_categorycontent');
// $crud->columns('ID','name_cat','createdt','createby','modifieddt','modifiedby');
// $crud->set_subject('Category Content');
// $crud->display_as('name_cat','Category');
// $crud->required_fields('name_cat');
// $this->HiddenField($crud);
// $output = $crud->render();
// $this->_home_output($output);
// }
function news()
{
$crud = new grocery_CRUD();
//$crud->set_model('MY_grocery_model');
$crud->set_table('star_news');
$crud->columns('ID','title','news','image','publish','createdt','createby','modifieddt','modifiedby');
$crud->set_subject('News');
$crud->required_fields('title','news','publish');
$crud->set_field_upload('image','assets/uploads/newsImg');
$crud->field_type('publish','dropdown',
array('1' => 'Publish Content', '2' => 'Disable Content'));
$this->HiddenField($crud);
$output = $crud->render();
$this->_home_output($output);
}
function HiddenField($crud)
{
//date_default_timezone_set("Asia/Jakarta");
$crud->field_type('createby', 'hidden','');
$crud->field_type('createdt', 'hidden','');
$crud->field_type('modifiedby', 'hidden','');
$crud->field_type('modifieddt', 'hidden','');
$url = explode('/',uri_string());
$c = count($url);
if($c > 3)
{
if($url[3] == 'add'){
$crud->field_type('createby', 'hidden',$this->user_data['username']);
$crud->field_type('createdt', 'hidden',date("Y-m-d H:i:s"));
} elseif($url[3] == 'edit') {
$crud->field_type('modifiedby', 'hidden',$this->user_data['username']);
$crud->field_type('modifieddt', 'hidden',date("Y-m-d H:i:s"));
}
}
}
}