I have this controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dashboard extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->database();
$this->load->library(array('ion_auth','form_validation'));
$this->load->helper(array('url','language','form'));
$this->load->library('grocery_CRUD');
$this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth'));
$this->lang->load('auth');
}
public function index()
{
if (!$this->ion_auth->is_admin())
{
$this->session->set_flashdata('message', '<div class="alert alert-info" role="alert">You must be an admin to view this page</div>');
redirect('/');
}
$crud = new grocery_CRUD();
$crud->set_table('personals');
$crud->set_subject('Pessoas');
$crud->columns('nome','data_nascimento','nome_mae','nome_pai','estado_civil','sexo','regime_estado_civil','cpf','rg',
'data_exp_rg','orgao_exp_rg','ctps_serie','ctps_numero','ci_inss_numero','pis_pasep','country_id','naturalidade_id','user');
$crud->display_as('data_nascimento','Nascimento')->display_as('nome_mae','Nome Mãe')->display_as('nome_pai','Nome Pai')
->display_as('regime_estado_civil','Reg Casamen')->display_as('data_exp_rg','Expira RG')->display_as('orgao_exp_rg','Orgão RG')
->display_as('country_id','Nacionalidade')->display_as('naturalidade_id','Naturalidade')->display_as('user','Nome Usuar');
$crud->set_relation('country_id','countries','nome');
$crud->set_relation('user_id','users','{id}.{username}');
$crud->callback_column('user', array($this, '_callback_webpage_url'));
$output = $crud->render();
$this->_example_output($output);
}
public function _callback_webpage_url($value, $row)
{
return '<a href="'.base_url("user_view/index/".$row->user_id).'">'.$row->user_id.'</a>';
}
function _example_output($output = null)
{
$this->load->view('admin/template/header');
$this->load->view('admin/dashboard',$output);
$this->load->view('admin/template/footer');
}
}
This let me link users table by id in column user.
That you can see in Nome Usuar column. But I need put in that column the username instead the user_id. How can I do that.
Sorry my english.